Magic-Drawings / app.py
arxivgpt kim
Update app.py
77a81d2 verified
raw
history blame
2.09 kB
import gradio as gr
from gradio_client import Client
def get_caption(image_in):
client = Client("https://vikhyatk-moondream1.hf.space/")
caption = client.predict(
image_in, # 'image_in'은 이미지 파일의 경로입니다.
"Describe the image", # 'Describe the image'는 모델에 제출되는 문장입니다.
api_name="/answer_question"
)
print(caption)
return caption # caption 변수는 이미지 설명 문자열을 담고 있습니다.
def get_lcm(prompt):
client = Client("https://latent-consistency-lcm-lora-for-sdxl.hf.space/")
# Consistent indentation for 'client.predict' call
results = client.predict(
prompt, # 'parameter_5' 텍스트박스 컴포넌트의 문자열
0.3, # 'Guidance' 슬라이더 컴포넌트의 0.0과 5 사이의 부동소수점 값
8, # 'Steps' 슬라이더 컴포넌트의 2와 10 사이의 부동소수점 값
0, # 'Seed' 슬라이더 컴포넌트의 0과 12013012031030 사이의 부동소수점 값
True, # 'Randomize' 체크박스 컴포넌트의 불리언 값
api_name="/predict"
)
# Process results and possibly call predict multiple times if multiple images are needed
print(results)
return results # 실제 API 응답에 기반한 반환 구문
def infer(image_in):
caption = get_caption(image_in)
# 이 부분은 get_lcm 함수가 올바른 이미지를 생성하고 반환하도록 구현해야 합니다.
# img_var = get_lcm(caption)
# 예제에서는 단순히 이미지 경로를 반환하도록 생략합니다.
return image_in # 실제로는 get_lcm 함수의 결과를 반환해야 합니다.
# Create an Interface object with proper parameters
interface = gr.Interface(
title="ArXivGPT Image",
description="Image to Image variation, using LCM SDXL & Moondream1",
fn=infer,
inputs=gr.Image(type="filepath", label="Image input"),
outputs=gr.Image(label="Image variation")
)
# Launch the interface
interface.queue(max_size=25).launch()