-
-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #187 from erictik/face-swap
add face swap
- Loading branch information
Showing
18 changed files
with
1,939 additions
and
53 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
.github/workflows/releases-4.2.yaml → .github/workflows/v4.3.x.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import "dotenv/config"; | ||
import { Midjourney, detectBannedWords } from "../src"; | ||
/** | ||
* | ||
* a simple example of how to use faceSwap | ||
* ``` | ||
* npx tsx example/faceswap.ts | ||
* ``` | ||
*/ | ||
async function main() { | ||
const source = `https://cdn.discordapp.com/attachments/1107965981839605792/1129362418775113789/3829c5d7-3e7e-473c-9c7b-b858e3ec97bc.jpeg`; | ||
// const source = `https://cdn.discordapp.com/attachments/1108587422389899304/1129321826804306031/guapitu006_Cute_warrior_girl_in_the_style_of_Baten_Kaitos__111f39bc-329e-4fab-9af7-ee219fedf260.png`; | ||
const target = `https://cdn.discordapp.com/attachments/1108587422389899304/1129321837042602016/guapitu006_a_girls_face_with_david_bowies_thunderbolt_71ee5899-bd45-4fc4-8c9d-92f19ddb0a03.png`; | ||
const client = new Midjourney({ | ||
ServerId: <string>process.env.SERVER_ID, | ||
ChannelId: <string>process.env.CHANNEL_ID, | ||
SalaiToken: <string>process.env.SALAI_TOKEN, | ||
Debug: true, | ||
HuggingFaceToken: <string>process.env.HUGGINGFACE_TOKEN, | ||
}); | ||
|
||
const info = await client.FaceSwap(target, source); | ||
console.log(info); | ||
} | ||
main() | ||
.then(() => { | ||
console.log("finished"); | ||
process.exit(0); | ||
}) | ||
.catch((err) => { | ||
console.error(err); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { client } from "./gradio/index"; | ||
|
||
export class faceSwap { | ||
public hf_token?: string; | ||
constructor(hf_token?: string) { | ||
this.hf_token = hf_token; | ||
} | ||
async changeFace(Target: Blob, Source: Blob) { | ||
const app = await client("https://felixrosberg-face-swap.hf.space/", { | ||
hf_token: this.hf_token as any, | ||
}); | ||
// console.log("app", app); | ||
const result: any = await app.predict(1, [ | ||
Target, // blob in 'Target' Image component | ||
Source, // blob in 'Source' Image component | ||
0, // number (numeric value between 0 and 100) in 'Anonymization ratio (%)' Slider component | ||
0, // number (numeric value between 0 and 100) in 'Adversarial defense ratio (%)' Slider component | ||
"Compare", // string[] (array of strings) in 'Mode' Checkboxgroup component | ||
]); | ||
// result.data; | ||
return result.data; | ||
// console.log(result.data[0]); | ||
} | ||
} |
Oops, something went wrong.