Spaces:
Running
Running
| import gradio as gr | |
| from gradio_client import Client | |
| def get_caption(image_in): | |
| client = Client("https://vikhyatk-moondream1.hf.space/") | |
| results = client.predict( | |
| prompt, # existing parameters | |
| num_images=4, # New parameter to request 4 images. This parameter may be different for the actual API. | |
| ) | |
| # Print and return the results assuming it contains 4 images | |
| print(results) | |
| return results[:4] # Return first 4 images in case the API returns more | |
| def get_lcm(prompt): | |
| client = Client("https://latent-consistency-lcm-lora-for-sdxl.hf.space/") | |
| # 'client.predict' 호출에서 들여쓰기가 올바른지 확인해야 합니다. | |
| 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" | |
| ) | |
| # 결과 처리 및 여러 이미지가 필요한 경우 여러 번 'predict'를 호출할 수 있습니다. | |
| print(results) | |
| return results # 실제 반환값을 위한 플레이스홀더, 여러 예측을 모으는 것을 고려해 보세요. | |
| # 코드의 나머지 부분이 일관된 들여쓰기를 유지하면서 작성됩니다. | |
| def infer(image_in): | |
| caption = get_caption(image_in) | |
| img_var = get_lcm(caption) | |
| return img_var | |
| 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") | |
| ] | |
| ).queue(max_size=25).launch() |