Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
@@ -429,8 +429,8 @@ class InputImage(BaseModel):
|
|
429 |
|
430 |
@app.post("/Immagine")
|
431 |
def generate_image(request: Request, input_data: InputImage):
|
432 |
-
client = Client("https://manjushri-sdxl-1-0.hf.space/")
|
433 |
-
|
434 |
if input_data.style:
|
435 |
print(input_data.style)
|
436 |
if input_data.style == 'RANDOM':
|
@@ -442,26 +442,16 @@ def generate_image(request: Request, input_data: InputImage):
|
|
442 |
style_info = style_image[input_data.style]
|
443 |
input_data.input = style_info["descrizione"].format(prompt=input_data.input)
|
444 |
input_data.negativePrompt = style_info["negativePrompt"]
|
445 |
-
max_attempts =
|
446 |
attempt = 0
|
447 |
while attempt < max_attempts:
|
448 |
try:
|
449 |
result = client.predict(
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
input_data.steps, # int | float (numeric value between 25 and 100) in 'Number of Iterations' Slider component
|
456 |
-
0, # int | float (numeric value between 0 and 999999999999999999) in 'Seed: 0 is Random' Slider component
|
457 |
-
"Yes", # str in 'Upscale?' Radio component
|
458 |
-
"", # str in 'Embedded Prompt' Textbox component
|
459 |
-
"", # str in 'Embedded Negative Prompt' Textbox component
|
460 |
-
0.99, # int | float (numeric value between 0.7 and 0.99) in 'Refiner Denoise Start %' Slider component
|
461 |
-
100, # int | float (numeric value between 1 and 100) in 'Refiner Number of Iterations %' Slider component
|
462 |
-
api_name="/predict"
|
463 |
-
)
|
464 |
-
image_url = result[0]
|
465 |
print(image_url)
|
466 |
with open(image_url, 'rb') as img_file:
|
467 |
img_binary = img_file.read()
|
|
|
429 |
|
430 |
@app.post("/Immagine")
|
431 |
def generate_image(request: Request, input_data: InputImage):
|
432 |
+
#client = Client("https://manjushri-sdxl-1-0.hf.space/")
|
433 |
+
client = Client("AP123/SDXL-Lightning")
|
434 |
if input_data.style:
|
435 |
print(input_data.style)
|
436 |
if input_data.style == 'RANDOM':
|
|
|
442 |
style_info = style_image[input_data.style]
|
443 |
input_data.input = style_info["descrizione"].format(prompt=input_data.input)
|
444 |
input_data.negativePrompt = style_info["negativePrompt"]
|
445 |
+
max_attempts = 5
|
446 |
attempt = 0
|
447 |
while attempt < max_attempts:
|
448 |
try:
|
449 |
result = client.predict(
|
450 |
+
input_data.input,
|
451 |
+
"8-Step",
|
452 |
+
api_name="/generate_image"
|
453 |
+
)
|
454 |
+
image_url = result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
455 |
print(image_url)
|
456 |
with open(image_url, 'rb') as img_file:
|
457 |
img_binary = img_file.read()
|