File size: 2,041 Bytes
6d35cbb
 
 
 
 
32ea1b8
 
 
6d35cbb
32ea1b8
 
 
7712ec1
6d35cbb
 
2f1fdee
4a6b70e
2f1fdee
 
 
 
 
 
4a6b70e
32ea1b8
2f1fdee
4a6b70e
2f1fdee
4a6b70e
2f1fdee
6d35cbb
 
 
32ea1b8
 
6d35cbb
 
32ea1b8
 
 
 
6d35cbb
 
32ea1b8
 
6d35cbb
32ea1b8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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()