fffiloni commited on
Commit
1bb2af8
·
verified ·
1 Parent(s): 33b0931

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -8
app.py CHANGED
@@ -27,24 +27,37 @@ def get_lcm(prompt):
27
  print(result)
28
  return result[0]
29
 
30
- def infer(image_in):
 
 
 
 
 
 
 
 
 
31
  caption = get_caption(image_in)
32
- img_var = get_lcm(caption)
 
 
 
33
  return img_var
34
 
35
  gr.Interface(
36
  title = "Supa Fast Image Variation",
37
- description = "Get quick image variation from image input, using <a href='https://huggingface.co/vikhyatk/moondream1' target='_blank'>moondream1</a> for caption, and <a href='https://huggingface.co/spaces/latent-consistency/lcm-lora-for-sdxl' target='_blank'>LCM SDXL</a> for image generation",
38
  fn = infer,
39
  inputs = [
40
- gr.Image(type="filepath", label="Image input")
 
41
  ],
42
  outputs = [
43
- gr.Image(label="LCM Image variation")
44
  ],
45
  examples = [
46
- "examples/frog_clean.jpg",
47
- "examples/martin_pecheur.jpeg",
48
- "examples/forest_deer.png"
49
  ]
50
  ).queue(max_size=25).launch(show_api=False, show_error=True)
 
27
  print(result)
28
  return result[0]
29
 
30
+ def get_sdxl_lightning(prompt):
31
+ client = Client("AP123/SDXL-Lightning")
32
+ result = client.predict(
33
+ prompt, # str in 'parameter_1' Textbox component
34
+ api_name="/predict"
35
+ )
36
+ print(result)
37
+ return result
38
+
39
+ def infer(image_in, chosen_method):
40
  caption = get_caption(image_in)
41
+ if chosen_method == "LCM" :
42
+ img_var = get_lcm(caption)
43
+ elif chosen_method == "SDXL Lightning" :
44
+ img_var = get_sdxl_lightning(caption)
45
  return img_var
46
 
47
  gr.Interface(
48
  title = "Supa Fast Image Variation",
49
+ description = "Get quick image variation from image input, using <a href='https://huggingface.co/vikhyatk/moondream1' target='_blank'>moondream1</a> for caption, and <a href='https://huggingface.co/spaces/latent-consistency/lcm-lora-for-sdxl' target='_blank'>LCM SDXL</a> or <a href='https://huggingface.co/spaces/AP123/SDXL-Lightning' target='_blank'>SDXL Lightning</a> for image generation",
50
  fn = infer,
51
  inputs = [
52
+ gr.Image(type="filepath", label="Image input"),
53
+ gr.Dropdown(label="Choose a model", choices=["LCM", "SDXL Lightning"], value="SDXL Lightning")
54
  ],
55
  outputs = [
56
+ gr.Image(label="Image variation")
57
  ],
58
  examples = [
59
+ ["examples/frog_clean.jpg", "SDXL Lightning"],
60
+ ["examples/martin_pecheur.jpeg", "LCM"],
61
+ ["examples/forest_deer.png", "SDXL Lightning"]
62
  ]
63
  ).queue(max_size=25).launch(show_api=False, show_error=True)