Spaces:
Runtime error
Runtime error
clementrof
commited on
Commit
•
a117519
1
Parent(s):
e50be38
Update app3.py
Browse files
app3.py
CHANGED
@@ -45,35 +45,48 @@ def SD_call(prompt, image_prompt, age, weight, color, hair_color,hair_length,hai
|
|
45 |
|
46 |
# Define your data (this could also be a JSON payload)
|
47 |
print("SD_processing")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
data = {
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
"refiner_checkpoint": "",
|
61 |
-
"refiner_switch_at": 0.8,
|
62 |
-
"prompt": f"{total_prompt}, {positive}",
|
63 |
-
"negative_prompt": f"EasyNegative, fat, paintings, sketches, lowres, ((monochrome)), ((grayscale)), bad anatomy, text, error, cropped, signature, watermark, username, blurry, bad feet, poorly drawn face, bad proportions, gross proportions, ng_deepnegative_v1_75t, badhandsv5-neg, {negative}",
|
64 |
-
"seed": -1,
|
65 |
-
"batch_size": 1,
|
66 |
-
"steps": 30,
|
67 |
-
"cfg_scale": 7,
|
68 |
-
"width": 520,
|
69 |
-
"height": 520,
|
70 |
-
"sampler_name": "DPM++ SDE Karras",
|
71 |
-
"sampler_index": "DPM++ SDE Karras",
|
72 |
-
"restore_faces": False
|
73 |
-
}
|
74 |
-
}
|
75 |
}
|
76 |
-
|
77 |
|
78 |
|
79 |
|
@@ -89,6 +102,7 @@ def SD_call(prompt, image_prompt, age, weight, color, hair_color,hair_length,hai
|
|
89 |
# Poll the status until it's not 'IN_QUEUE'
|
90 |
while response_data['status'] == 'IN_QUEUE':
|
91 |
time.sleep(5) # Wait for 5 seconds before checking again
|
|
|
92 |
response = requests.get(f"{url}/{msg_id}", headers=headers)
|
93 |
|
94 |
try:
|
@@ -100,6 +114,7 @@ def SD_call(prompt, image_prompt, age, weight, color, hair_color,hair_length,hai
|
|
100 |
|
101 |
# Check if the response contains images
|
102 |
if 'images' in response_data.get('output', {}):
|
|
|
103 |
base64_image = response_data['output']['images'][0]
|
104 |
image_bytes = base64.b64decode(base64_image)
|
105 |
|
@@ -125,7 +140,11 @@ def SD_call(prompt, image_prompt, age, weight, color, hair_color,hair_length,hai
|
|
125 |
|
126 |
def greet(prompt, image_prompt, age, weight, color, hair_color,hair_length,hair_texture,skin_details,eye_colors,NSFW):
|
127 |
image_path = SD_call(prompt, image_prompt, age, weight, color, hair_color,hair_length,hair_texture,skin_details,eye_colors,NSFW)
|
128 |
-
return "Image generated successfully", image_path
|
|
|
|
|
|
|
|
|
129 |
|
130 |
|
131 |
demo = gr.Interface(
|
|
|
45 |
|
46 |
# Define your data (this could also be a JSON payload)
|
47 |
print("SD_processing")
|
48 |
+
# data = {
|
49 |
+
# "input": {
|
50 |
+
# "api": {
|
51 |
+
# "method": "POST",
|
52 |
+
# "endpoint": "/sdapi/v1/txt2img"
|
53 |
+
# },
|
54 |
+
# "payload": {
|
55 |
+
# "override_settings": {
|
56 |
+
# "sd_model_checkpoint": "CyberRealistic",
|
57 |
+
# "sd_vae": ""
|
58 |
+
# },
|
59 |
+
# "override_settings_restore_afterwards": True,
|
60 |
+
# "refiner_checkpoint": "",
|
61 |
+
# "refiner_switch_at": 0.8,
|
62 |
+
# "prompt": f"{total_prompt}, {positive}",
|
63 |
+
# "negative_prompt": f"EasyNegative, fat, paintings, sketches, lowres, ((monochrome)), ((grayscale)), bad anatomy, text, error, cropped, signature, watermark, username, blurry, bad feet, poorly drawn face, bad proportions, gross proportions, ng_deepnegative_v1_75t, badhandsv5-neg, {negative}",
|
64 |
+
# "seed": -1,
|
65 |
+
# "batch_size": 1,
|
66 |
+
# "steps": 30,
|
67 |
+
# "cfg_scale": 7,
|
68 |
+
# "width": 520,
|
69 |
+
# "height": 520,
|
70 |
+
# "sampler_name": "DPM++ SDE Karras",
|
71 |
+
# "sampler_index": "DPM++ SDE Karras",
|
72 |
+
# "restore_faces": False
|
73 |
+
# }
|
74 |
+
# }
|
75 |
+
# }
|
76 |
+
|
77 |
data = {
|
78 |
+
"input": {
|
79 |
+
"prompt": f"{total_prompt}, {positive}",
|
80 |
+
"negative_prompt": f"EasyNegative, fat, paintings, sketches, lowres, ((monochrome)), ((grayscale)), bad anatomy, text, error, cropped, signature, watermark, username, blurry, bad feet, poorly drawn face, bad proportions, gross proportions, ng_deepnegative_v1_75t, badhandsv5-neg, {negative}",
|
81 |
+
"width": 512,
|
82 |
+
"height": 720,
|
83 |
+
"guidance_scale": 7.5,
|
84 |
+
"num_inference_steps": 50,
|
85 |
+
"num_outputs": 1,
|
86 |
+
"prompt_strength": 0.8,
|
87 |
+
"scheduler": "K-LMS"
|
88 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
}
|
|
|
90 |
|
91 |
|
92 |
|
|
|
102 |
# Poll the status until it's not 'IN_QUEUE'
|
103 |
while response_data['status'] == 'IN_QUEUE':
|
104 |
time.sleep(5) # Wait for 5 seconds before checking again
|
105 |
+
print("1")
|
106 |
response = requests.get(f"{url}/{msg_id}", headers=headers)
|
107 |
|
108 |
try:
|
|
|
114 |
|
115 |
# Check if the response contains images
|
116 |
if 'images' in response_data.get('output', {}):
|
117 |
+
print("image")
|
118 |
base64_image = response_data['output']['images'][0]
|
119 |
image_bytes = base64.b64decode(base64_image)
|
120 |
|
|
|
140 |
|
141 |
def greet(prompt, image_prompt, age, weight, color, hair_color,hair_length,hair_texture,skin_details,eye_colors,NSFW):
|
142 |
image_path = SD_call(prompt, image_prompt, age, weight, color, hair_color,hair_length,hair_texture,skin_details,eye_colors,NSFW)
|
143 |
+
#return "Image generated successfully", image_path
|
144 |
+
if image_path is not None:
|
145 |
+
return "Image generated successfully", image_path
|
146 |
+
else:
|
147 |
+
return "No images found in the response.", None
|
148 |
|
149 |
|
150 |
demo = gr.Interface(
|