Spaces:
Sleeping
Sleeping
Delete clothGen.py
Browse files- clothGen.py +0 -59
clothGen.py
DELETED
@@ -1,59 +0,0 @@
|
|
1 |
-
import fal_client
|
2 |
-
import pandas as pd
|
3 |
-
from prompt_gen import prompt_gen
|
4 |
-
import requests
|
5 |
-
import os
|
6 |
-
|
7 |
-
nv_prompt_file = pd.read_excel('汉服-女词库.xlsx')
|
8 |
-
na_prompt_file = pd.read_excel('汉服-男词库.xlsx')
|
9 |
-
nv_prompt = nv_prompt_file.to_string(index=False)
|
10 |
-
na_prompt = na_prompt_file.to_string(index=False)
|
11 |
-
|
12 |
-
def cloth_gen(advice, gender):
|
13 |
-
lora_path = "https://huggingface.co/PPSharks/PPSharksModels/resolve/main/NV.safetensors"
|
14 |
-
if gender == "男":
|
15 |
-
lora_path = "https://huggingface.co/PPSharks/PPSharksModels/resolve/main/NA.safetensors"
|
16 |
-
else:
|
17 |
-
lora_path = "https://huggingface.co/PPSharks/PPSharksModels/resolve/main/NV.safetensors"
|
18 |
-
|
19 |
-
prompt = prompt_gen(advice, gender)
|
20 |
-
prompt_start = prompt.find("Prompt")
|
21 |
-
if prompt_start != -1:
|
22 |
-
prompt = prompt[prompt_start + len("Prompt"):].strip()
|
23 |
-
else:
|
24 |
-
print("No prompt found.")
|
25 |
-
|
26 |
-
handler = fal_client.submit(
|
27 |
-
"fal-ai/fast-sdxl",
|
28 |
-
arguments={
|
29 |
-
"prompt": prompt,
|
30 |
-
"negative_prompt": "face, male, female, people, person, man, woman, Multiple clothes, cartoon, illustration, animation.",
|
31 |
-
"image_size": "portrait_4_3",
|
32 |
-
"num_inference_steps": 28,
|
33 |
-
"guidance_scale": 7.5,
|
34 |
-
"num_images": 6,
|
35 |
-
"loras": [{"path": lora_path, "scale": 0.7}],
|
36 |
-
"embeddings": [],
|
37 |
-
"safety_checker_version": "v1",
|
38 |
-
"format": "jpeg"
|
39 |
-
},
|
40 |
-
)
|
41 |
-
|
42 |
-
request_id = handler.request_id
|
43 |
-
result = fal_client.result("fal-ai/fast-sdxl", request_id)
|
44 |
-
cloth_image = []
|
45 |
-
save_directory = "downloads"
|
46 |
-
image_index = 1
|
47 |
-
for image in result['images']:
|
48 |
-
response = requests.get(image['url'])
|
49 |
-
if response.status_code == 200:
|
50 |
-
filename = os.path.join(save_directory, f"gen_cloth_{image_index}.jpeg")
|
51 |
-
cloth_image.append(filename)
|
52 |
-
with open(filename, 'wb') as f:
|
53 |
-
f.write(response.content)
|
54 |
-
image_index += 1
|
55 |
-
else:
|
56 |
-
print(f"Failed to download image from {image['url']}")
|
57 |
-
return cloth_image
|
58 |
-
|
59 |
-
# cloth_gen()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|