Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
@@ -440,11 +440,12 @@ class InputImage(BaseModel):
|
|
440 |
steps: int = 25
|
441 |
cfg: int = 6
|
442 |
seed: int = -1
|
|
|
443 |
|
444 |
@app.post("/Immagine")
|
445 |
def generate_image(request: Request, input_data: InputImage):
|
446 |
#client = Client("https://manjushri-sdxl-1-0.hf.space/")
|
447 |
-
|
448 |
if input_data.style:
|
449 |
print(input_data.style)
|
450 |
if input_data.style == 'RANDOM':
|
@@ -461,11 +462,26 @@ def generate_image(request: Request, input_data: InputImage):
|
|
461 |
while attempt < max_attempts:
|
462 |
try:
|
463 |
print(input_data.input)
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
469 |
image_url = result
|
470 |
print(image_url)
|
471 |
with open(image_url, 'rb') as img_file:
|
|
|
440 |
steps: int = 25
|
441 |
cfg: int = 6
|
442 |
seed: int = -1
|
443 |
+
variante = False
|
444 |
|
445 |
@app.post("/Immagine")
|
446 |
def generate_image(request: Request, input_data: InputImage):
|
447 |
#client = Client("https://manjushri-sdxl-1-0.hf.space/")
|
448 |
+
|
449 |
if input_data.style:
|
450 |
print(input_data.style)
|
451 |
if input_data.style == 'RANDOM':
|
|
|
462 |
while attempt < max_attempts:
|
463 |
try:
|
464 |
print(input_data.input)
|
465 |
+
if input_data.variante = False:
|
466 |
+
client = Client("AP123/SDXL-Lightning")
|
467 |
+
result = client.predict(
|
468 |
+
input_data.input,
|
469 |
+
"8-Step",
|
470 |
+
api_name="/generate_image"
|
471 |
+
)
|
472 |
+
else:
|
473 |
+
client = Client("https://playgroundai-playground-v2-5.hf.space/--replicas/9kuov/")
|
474 |
+
result = client.predict(
|
475 |
+
input_data.input, # str in 'Prompt' Textbox component
|
476 |
+
input_data.negativePrompt, # str in 'Negative prompt' Textbox component
|
477 |
+
True, # bool in 'Use negative prompt' Checkbox component
|
478 |
+
0, # float (numeric value between 0 and 2147483647) in 'Seed' Slider component
|
479 |
+
1024, # float (numeric value between 256 and 1536) in 'Width' Slider component
|
480 |
+
1024, # float (numeric value between 256 and 1536) in 'Height' Slider component
|
481 |
+
3, # float (numeric value between 0.1 and 20) in 'Guidance Scale' Slider component
|
482 |
+
True, # bool in 'Randomize seed' Checkbox component
|
483 |
+
api_name="/run"
|
484 |
+
)
|
485 |
image_url = result
|
486 |
print(image_url)
|
487 |
with open(image_url, 'rb') as img_file:
|