MatteoScript commited on
Commit
96ad53d
·
verified ·
1 Parent(s): ca63b28

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +8 -18
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 = 2
446
  attempt = 0
447
  while attempt < max_attempts:
448
  try:
449
  result = client.predict(
450
- input_data.input, # str in 'What you want the AI to generate. 77 Token Limit. A Token is Any Word, Number, Symbol, or Punctuation. Everything Over 77 Will Be Truncated!' Textbox component
451
- input_data.negativePrompt, # str in 'What you Do Not want the AI to generate. 77 Token Limit' Textbox component
452
- 1024, # int | float (numeric value between 512 and 1024) in 'Height' Slider component
453
- 1024, # int | float (numeric value between 512 and 1024) in 'Width' Slider component
454
- input_data.cfg, # int | float (numeric value between 1 and 15) in 'Guidance Scale: How Closely the AI follows the Prompt' Slider component
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()