Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -16,17 +16,17 @@ import os
|
|
16 |
from PIL import Image
|
17 |
|
18 |
|
19 |
-
base_model="stabilityai/stable-diffusion-xl-base-1.0"
|
20 |
|
|
|
|
|
|
|
21 |
# base = DiffusionPipeline.from_pretrained(base_model,
|
22 |
# torch_dtype=torch.float16, use_safetensors=True
|
23 |
-
# )
|
24 |
-
|
25 |
-
torch_dtype=torch.float16, use_safetensors=True
|
26 |
-
)
|
27 |
-
# lora_model_path = "./pytorch_weights.safetensors"
|
28 |
|
29 |
-
# base.load_lora_weights(lora_model_path)
|
30 |
|
31 |
def swap_face(source_file, target_file,doFaceEnhancer):
|
32 |
|
@@ -90,37 +90,37 @@ def swap_face(source_file, target_file,doFaceEnhancer):
|
|
90 |
|
91 |
def generate_image(prompt, height=1024, width=1024):
|
92 |
|
93 |
-
image = base(
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
)
|
102 |
|
103 |
|
104 |
-
for i in range(len(image.images)):
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
# The source image for face swapping
|
110 |
-
source_image_path = "./roop/IMG_0991.png"
|
111 |
|
112 |
-
|
113 |
-
|
114 |
|
115 |
-
|
116 |
-
|
117 |
|
118 |
-
|
|
|
119 |
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
]
|
|
|
|
|
124 |
# Set up the Gradio interface
|
125 |
interface = gr.Interface(
|
126 |
fn=generate_image,
|
@@ -130,7 +130,7 @@ inputs=[
|
|
130 |
gr.Number(label="Width")
|
131 |
],
|
132 |
outputs=gr.Image(label="Image"),
|
133 |
-
examples=examples
|
134 |
|
135 |
)
|
136 |
|
|
|
16 |
from PIL import Image
|
17 |
|
18 |
|
19 |
+
# base_model="stabilityai/stable-diffusion-xl-base-1.0"
|
20 |
|
21 |
+
# # base = DiffusionPipeline.from_pretrained(base_model,
|
22 |
+
# # torch_dtype=torch.float16, use_safetensors=True
|
23 |
+
# # ).to("cuda")
|
24 |
# base = DiffusionPipeline.from_pretrained(base_model,
|
25 |
# torch_dtype=torch.float16, use_safetensors=True
|
26 |
+
# )
|
27 |
+
# # lora_model_path = "./pytorch_weights.safetensors"
|
|
|
|
|
|
|
28 |
|
29 |
+
# # base.load_lora_weights(lora_model_path)
|
30 |
|
31 |
def swap_face(source_file, target_file,doFaceEnhancer):
|
32 |
|
|
|
90 |
|
91 |
def generate_image(prompt, height=1024, width=1024):
|
92 |
|
93 |
+
# image = base(
|
94 |
+
# prompt=prompt,
|
95 |
+
# negative_prompt="(deformed iris, deformed pupils, semi-realistic, cgi, 3d, render, sketch, cartoon, drawing, anime), text, cropped, out of frame, worst quality, low quality, jpeg artifacts, ugly, duplicate, morbid, mutilated, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, mutation, deformed, blurry, dehydrated, bad anatomy, bad proportions, extra limbs, cloned face, disfigured, gross proportions, malformed limbs, missing arms, missing legs, extra arms, extra legs, fused fingers, too many fingers, long neck",
|
96 |
+
# num_inference_steps=40,
|
97 |
+
# guidance_scale=3,
|
98 |
+
# height=int(height),
|
99 |
+
# width=int(width),
|
100 |
+
# num_images_per_prompt=1,
|
101 |
+
# )
|
102 |
|
103 |
|
104 |
+
# for i in range(len(image.images)):
|
105 |
+
# # Save the generated images
|
106 |
+
# original_image_path = f"./output{i}.png"
|
107 |
+
# image.images[i].save(original_image_path)
|
|
|
|
|
|
|
108 |
|
109 |
+
# # The source image for face swapping
|
110 |
+
# source_image_path = "./roop/IMG_0991.png"
|
111 |
|
112 |
+
# # Run the face swap and optionally face enhancement
|
113 |
+
# swapped_image_path = swap_face(source_image_path, original_image_path, False)
|
114 |
|
115 |
+
# # Load the swapped image and add to the output list
|
116 |
+
# swapped_image = Image.open(swapped_image_path)
|
117 |
|
118 |
+
# return swapped_image
|
119 |
+
return None
|
120 |
+
# examples = [
|
121 |
+
# ["xkx man as superman. Uhd, 8k", 1024, 1024],
|
122 |
+
# ["photo of xkx man on a beach. Amazing scenery, waves, sun. Uhd, 8k", 1024, 1536],
|
123 |
+
# ]
|
124 |
# Set up the Gradio interface
|
125 |
interface = gr.Interface(
|
126 |
fn=generate_image,
|
|
|
130 |
gr.Number(label="Width")
|
131 |
],
|
132 |
outputs=gr.Image(label="Image"),
|
133 |
+
# examples=examples
|
134 |
|
135 |
)
|
136 |
|