|
import gradio as gr |
|
from gradio_client import Client |
|
|
|
def get_caption(image_in): |
|
client = Client("https://vikhyatk-moondream1.hf.space/") |
|
result = client.predict( |
|
image_in, |
|
"Describe the image", |
|
api_name="/answer_question" |
|
) |
|
print(result) |
|
return result |
|
|
|
def get_lcm(prompt): |
|
client = Client("https://latent-consistency-lcm-lora-for-sdxl.hf.space/") |
|
result = client.predict( |
|
prompt, |
|
0.3, |
|
8, |
|
0, |
|
True, |
|
api_name="/predict" |
|
) |
|
print(result) |
|
return result[0] |
|
|
|
def infer(image_in): |
|
caption = get_caption(image_in) |
|
img_var = get_lcm(caption) |
|
return img_var |
|
|
|
css = """ |
|
footer { |
|
visibility: hidden; |
|
} |
|
""" |
|
|
|
gr.Interface(css=css, |
|
fn = infer, |
|
inputs = [ |
|
gr.Image(type="filepath", label="Image input") |
|
], |
|
outputs = [ |
|
gr.Image(label="LCM Image variation") |
|
] |
|
).queue(max_size=25).launch() |
|
|
|
|