Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
@@ -167,14 +167,14 @@ class InputImage(BaseModel):
|
|
167 |
input: str
|
168 |
negativePrompt: str = ''
|
169 |
style: str = ''
|
170 |
-
steps: int =
|
171 |
-
cfg: int =
|
172 |
seed: int = -1
|
173 |
|
174 |
@app.post("/Immagine")
|
175 |
def generate_image(request: Request, input_data: InputImage):
|
176 |
-
|
177 |
-
client = Client("https://segmind-segmind-stable-diffusion.hf.space/--replicas/xc5bq/")
|
178 |
|
179 |
if input_data.style:
|
180 |
print(input_data.style)
|
@@ -192,44 +192,44 @@ def generate_image(request: Request, input_data: InputImage):
|
|
192 |
attempt = 0
|
193 |
while attempt < max_attempts:
|
194 |
try:
|
195 |
-
#result = client.predict(
|
196 |
-
# input_data.input, # str in 'Prompt' Textbox component
|
197 |
-
# input_data.negativePrompt, # str in 'Negative prompt' Textbox component
|
198 |
-
# input_data.input, # str in 'Prompt 2' Textbox component
|
199 |
-
# input_data.negativePrompt, # str in 'Negative prompt 2' Textbox component
|
200 |
-
# True, # bool in 'Use negative prompt' Checkbox component
|
201 |
-
# True, # bool in 'Use prompt 2' Checkbox component
|
202 |
-
# True, # bool in 'Use negative prompt 2' Checkbox component
|
203 |
-
# input_data.seed, # float (numeric value between 0 and 2147483647) in 'Seed' Slider component
|
204 |
-
# 1024, # float (numeric value between 256 and 1024) in 'Width' Slider component
|
205 |
-
# 1024, # float (numeric value between 256 and 1024) in 'Height' Slider component
|
206 |
-
# input_data.cfg, # float (numeric value between 1 and 20) in 'Guidance scale for base' Slider component
|
207 |
-
# input_data.cfg, # float (numeric value between 1 and 20) in 'Guidance scale for refiner' Slider component
|
208 |
-
# input_data.steps, # float (numeric value between 10 and 100) in 'Number of inference steps for base' Slider component
|
209 |
-
# input_data.steps, # float (numeric value between 10 and 100) in 'Number of inference steps for refiner' Slider component
|
210 |
-
# True, # bool in 'Apply refiner' Checkbox component
|
211 |
-
# api_name="/run"
|
212 |
-
#)
|
213 |
result = client.predict(
|
214 |
-
input_data.input,
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
True, # bool in 'Randomize seed' Checkbox component
|
231 |
-
api_name="/run"
|
232 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
233 |
image_url = result
|
234 |
with open(image_url, 'rb') as img_file:
|
235 |
img_binary = img_file.read()
|
|
|
167 |
input: str
|
168 |
negativePrompt: str = ''
|
169 |
style: str = ''
|
170 |
+
steps: int = 25
|
171 |
+
cfg: int = 6
|
172 |
seed: int = -1
|
173 |
|
174 |
@app.post("/Immagine")
|
175 |
def generate_image(request: Request, input_data: InputImage):
|
176 |
+
client = Client("https://hysts-sd-xl.hf.space/--replicas/cplz0/")
|
177 |
+
#client = Client("https://segmind-segmind-stable-diffusion.hf.space/--replicas/xc5bq/")
|
178 |
|
179 |
if input_data.style:
|
180 |
print(input_data.style)
|
|
|
192 |
attempt = 0
|
193 |
while attempt < max_attempts:
|
194 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
195 |
result = client.predict(
|
196 |
+
input_data.input, # str in 'Prompt' Textbox component
|
197 |
+
input_data.negativePrompt, # str in 'Negative prompt' Textbox component
|
198 |
+
input_data.input, # str in 'Prompt 2' Textbox component
|
199 |
+
input_data.negativePrompt, # str in 'Negative prompt 2' Textbox component
|
200 |
+
True, # bool in 'Use negative prompt' Checkbox component
|
201 |
+
True, # bool in 'Use prompt 2' Checkbox component
|
202 |
+
True, # bool in 'Use negative prompt 2' Checkbox component
|
203 |
+
input_data.seed, # float (numeric value between 0 and 2147483647) in 'Seed' Slider component
|
204 |
+
1024, # float (numeric value between 256 and 1024) in 'Width' Slider component
|
205 |
+
1024, # float (numeric value between 256 and 1024) in 'Height' Slider component
|
206 |
+
input_data.cfg, # float (numeric value between 1 and 20) in 'Guidance scale for base' Slider component
|
207 |
+
input_data.cfg, # float (numeric value between 1 and 20) in 'Guidance scale for refiner' Slider component
|
208 |
+
input_data.steps, # float (numeric value between 10 and 100) in 'Number of inference steps for base' Slider component
|
209 |
+
input_data.steps, # float (numeric value between 10 and 100) in 'Number of inference steps for refiner' Slider component
|
210 |
+
True, # bool in 'Apply refiner' Checkbox component
|
211 |
+
api_name="/run"
|
|
|
|
|
212 |
)
|
213 |
+
#result = client.predict(
|
214 |
+
# input_data.input, # str in 'Prompt' Textbox component
|
215 |
+
# input_data.negativePrompt, # str in 'Negative prompt' Textbox component
|
216 |
+
# "(No style)", # str in 'Image Style' Radio component
|
217 |
+
# "", # str in 'Prompt 2' Textbox component
|
218 |
+
# "", # str in 'Negative prompt 2' Textbox component
|
219 |
+
# True, # bool in 'Use negative prompt' Checkbox component
|
220 |
+
# False, # bool in 'Use prompt 2' Checkbox component
|
221 |
+
# False, # bool in 'Use negative prompt 2' Checkbox component
|
222 |
+
# 0, # int | float (numeric value between 0 and 2147483647) in 'Seed' Slider component
|
223 |
+
# 1024, # int | float (numeric value between 256 and 1024) in 'Width' Slider component
|
224 |
+
# 1024, # int | float (numeric value between 256 and 1024) in 'Height' Slider component
|
225 |
+
# input_data.cfg, # int | float (numeric value between 1 and 20) in 'Guidance scale for base' Slider component
|
226 |
+
# input_data.cfg, # int | float (numeric value between 1 and 20) in 'Guidance scale for refiner' Slider component
|
227 |
+
# input_data.steps, # int | float (numeric value between 10 and 100) in 'Number of inference steps for base' Slider component
|
228 |
+
# input_data.steps, # int | float (numeric value between 10 and 100) in 'Number of inference steps for refiner' Slider component
|
229 |
+
# True, # bool in 'Apply refiner' Checkbox component
|
230 |
+
# True, # bool in 'Randomize seed' Checkbox component
|
231 |
+
# api_name="/run"
|
232 |
+
#)
|
233 |
image_url = result
|
234 |
with open(image_url, 'rb') as img_file:
|
235 |
img_binary = img_file.read()
|