Update app.py
Browse files
app.py
CHANGED
|
@@ -11,7 +11,7 @@ from moviepy import VideoFileClip
|
|
| 11 |
from datetime import datetime, timedelta
|
| 12 |
from huggingface_hub import hf_hub_download, snapshot_download, login
|
| 13 |
HF_TOKEN=os.environ.get('HF_TOKEN')
|
| 14 |
-
login(token=HF_TOKEN)
|
| 15 |
import insightface
|
| 16 |
from insightface.app import FaceAnalysis
|
| 17 |
from facexlib.parsing import init_parsing_model
|
|
@@ -41,7 +41,7 @@ snapshot_download(repo_id="BestWishYsh/ConsisID-preview", local_dir="BestWishYsh
|
|
| 41 |
model_path = "BestWishYsh/ConsisID-preview"
|
| 42 |
lora_path = None
|
| 43 |
lora_rank = 128
|
| 44 |
-
dtype = torch.
|
| 45 |
|
| 46 |
if os.path.exists(os.path.join(model_path, "transformer_ema")):
|
| 47 |
subfolder = "transformer_ema"
|
|
@@ -139,15 +139,8 @@ def delete_old_files():
|
|
| 139 |
if file_mtime < cutoff:
|
| 140 |
os.remove(file_path)
|
| 141 |
time.sleep(600)
|
| 142 |
-
|
| 143 |
-
def infer(
|
| 144 |
-
prompt: str,
|
| 145 |
-
image_input: str,
|
| 146 |
-
num_inference_steps: int,
|
| 147 |
-
guidance_scale: float,
|
| 148 |
-
seed: int = 42,
|
| 149 |
-
progress=gr.Progress(track_tqdm=True),
|
| 150 |
-
):
|
| 151 |
if seed == -1:
|
| 152 |
seed = random.randint(0, 2**8 - 1)
|
| 153 |
|
|
@@ -178,24 +171,19 @@ def infer(
|
|
| 178 |
prompt=prompt,
|
| 179 |
image=image,
|
| 180 |
num_videos_per_prompt=1,
|
| 181 |
-
num_inference_steps=
|
| 182 |
num_frames=49,
|
| 183 |
use_dynamic_cfg=False,
|
| 184 |
-
guidance_scale=
|
| 185 |
generator=generator,
|
| 186 |
id_vit_hidden=id_vit_hidden,
|
| 187 |
id_cond=id_cond,
|
| 188 |
kps_cond=kps_cond,
|
| 189 |
output_type="pt",
|
| 190 |
).frames
|
| 191 |
-
|
| 192 |
-
##free_memory()
|
| 193 |
-
return video_pt, seed
|
| 194 |
-
##threading.Thread(target=delete_old_files, daemon=True).start()
|
| 195 |
-
@spaces.GPU(duration=70)
|
| 196 |
-
def generate(prompt,image_input,seed_value,scale_status,rife_status,progress=gr.Progress(track_tqdm=True)):
|
| 197 |
|
| 198 |
-
latents
|
|
|
|
| 199 |
if scale_status:
|
| 200 |
latents = upscale_batch_and_concatenate(upscale_model, latents, device)
|
| 201 |
if rife_status:
|
|
@@ -219,6 +207,8 @@ def generate(prompt,image_input,seed_value,scale_status,rife_status,progress=gr.
|
|
| 219 |
|
| 220 |
return video_path, video_update, gif_update, seed_update
|
| 221 |
|
|
|
|
|
|
|
| 222 |
|
| 223 |
examples_images = [
|
| 224 |
["asserts/example_images/1.png", "A woman adorned with a delicate flower crown, is standing amidst a field of gently swaying wildflowers. Her eyes sparkle with a serene gaze, and a faint smile graces her lips, suggesting a moment of peaceful contentment. The shot is framed from the waist up, highlighting the gentle breeze lightly tousling her hair. The background reveals an expansive meadow under a bright blue sky, capturing the tranquility of a sunny afternoon."],
|
|
|
|
| 11 |
from datetime import datetime, timedelta
|
| 12 |
from huggingface_hub import hf_hub_download, snapshot_download, login
|
| 13 |
HF_TOKEN=os.environ.get('HF_TOKEN')
|
| 14 |
+
##login(token=HF_TOKEN)
|
| 15 |
import insightface
|
| 16 |
from insightface.app import FaceAnalysis
|
| 17 |
from facexlib.parsing import init_parsing_model
|
|
|
|
| 41 |
model_path = "BestWishYsh/ConsisID-preview"
|
| 42 |
lora_path = None
|
| 43 |
lora_rank = 128
|
| 44 |
+
dtype = torch.bfloat16
|
| 45 |
|
| 46 |
if os.path.exists(os.path.join(model_path, "transformer_ema")):
|
| 47 |
subfolder = "transformer_ema"
|
|
|
|
| 139 |
if file_mtime < cutoff:
|
| 140 |
os.remove(file_path)
|
| 141 |
time.sleep(600)
|
| 142 |
+
@spaces.GPU(duration=70)
|
| 143 |
+
def infer(prompt,image_input,seed_value,scale_status,rife_status,progress=gr.Progress(track_tqdm=True)):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 144 |
if seed == -1:
|
| 145 |
seed = random.randint(0, 2**8 - 1)
|
| 146 |
|
|
|
|
| 171 |
prompt=prompt,
|
| 172 |
image=image,
|
| 173 |
num_videos_per_prompt=1,
|
| 174 |
+
num_inference_steps=4,
|
| 175 |
num_frames=49,
|
| 176 |
use_dynamic_cfg=False,
|
| 177 |
+
guidance_scale=7.0,
|
| 178 |
generator=generator,
|
| 179 |
id_vit_hidden=id_vit_hidden,
|
| 180 |
id_cond=id_cond,
|
| 181 |
kps_cond=kps_cond,
|
| 182 |
output_type="pt",
|
| 183 |
).frames
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
|
| 185 |
+
latents = video_pt
|
| 186 |
+
##free_memory()
|
| 187 |
if scale_status:
|
| 188 |
latents = upscale_batch_and_concatenate(upscale_model, latents, device)
|
| 189 |
if rife_status:
|
|
|
|
| 207 |
|
| 208 |
return video_path, video_update, gif_update, seed_update
|
| 209 |
|
| 210 |
+
##return video_pt, seed
|
| 211 |
+
##threading.Thread(target=delete_old_files, daemon=True).start()
|
| 212 |
|
| 213 |
examples_images = [
|
| 214 |
["asserts/example_images/1.png", "A woman adorned with a delicate flower crown, is standing amidst a field of gently swaying wildflowers. Her eyes sparkle with a serene gaze, and a faint smile graces her lips, suggesting a moment of peaceful contentment. The shot is framed from the waist up, highlighting the gentle breeze lightly tousling her hair. The background reveals an expansive meadow under a bright blue sky, capturing the tranquility of a sunny afternoon."],
|