Spaces:
Running
Running
arxivgpt kim
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -2,46 +2,51 @@ import gradio as gr
|
|
2 |
from gradio_client import Client
|
3 |
|
4 |
def get_caption(image_in):
|
|
|
5 |
client = Client("https://vikhyatk-moondream1.hf.space/")
|
6 |
-
|
7 |
-
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
9 |
)
|
10 |
-
# Print and return the results assuming it contains
|
11 |
print(results)
|
12 |
-
return results
|
13 |
|
14 |
def get_lcm(prompt):
|
15 |
client = Client("https://latent-consistency-lcm-lora-for-sdxl.hf.space/")
|
16 |
-
|
|
|
17 |
results = client.predict(
|
18 |
prompt, # 'parameter_5' 텍스트박스 컴포넌트의 문자열
|
19 |
0.3, # 'Guidance' 슬라이더 컴포넌트의 0.0과 5 사이의 부동소수점 값
|
20 |
8, # 'Steps' 슬라이더 컴포넌트의 2와 10 사이의 부동소수점 값
|
21 |
0, # 'Seed' 슬라이더 컴포넌트의 0과 12013012031030 사이의 부동소수점 값
|
22 |
True, # 'Randomize' 체크박스 컴포넌트의 불리언 값
|
23 |
-
# 필요한 경우 여기에 더 많은 파라미터를 추가할 수 있습니다.
|
24 |
api_name="/predict"
|
25 |
)
|
26 |
-
|
|
|
27 |
print(results)
|
28 |
-
return results # 실제
|
29 |
-
|
30 |
-
# 코드의 나머지 부분이 일관된 들여쓰기를 유지하면서 작성됩니다.
|
31 |
|
32 |
def infer(image_in):
|
33 |
caption = get_caption(image_in)
|
34 |
img_var = get_lcm(caption)
|
35 |
return img_var
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
|
|
2 |
from gradio_client import Client
|
3 |
|
4 |
def get_caption(image_in):
|
5 |
+
# Correct indentation before client initialization
|
6 |
client = Client("https://vikhyatk-moondream1.hf.space/")
|
7 |
+
|
8 |
+
# Align the call to 'client.predict' with the line above
|
9 |
+
# Also, the parameter 'prompt' is not defined in 'get_caption'.
|
10 |
+
# It should be 'image_in' to match the function signature.
|
11 |
+
results = client.predict(
|
12 |
+
image_in, # Use the 'image_in' parameter as input to the model
|
13 |
+
"Describe the image", # Assuming this is a constant parameter for the model
|
14 |
+
api_name="/answer_question"
|
15 |
)
|
16 |
+
# Print and return the results assuming it contains the description
|
17 |
print(results)
|
18 |
+
return results
|
19 |
|
20 |
def get_lcm(prompt):
|
21 |
client = Client("https://latent-consistency-lcm-lora-for-sdxl.hf.space/")
|
22 |
+
|
23 |
+
# Consistent indentation for 'client.predict' call
|
24 |
results = client.predict(
|
25 |
prompt, # 'parameter_5' 텍스트박스 컴포넌트의 문자열
|
26 |
0.3, # 'Guidance' 슬라이더 컴포넌트의 0.0과 5 사이의 부동소수점 값
|
27 |
8, # 'Steps' 슬라이더 컴포넌트의 2와 10 사이의 부동소수점 값
|
28 |
0, # 'Seed' 슬라이더 컴포넌트의 0과 12013012031030 사이의 부동소수점 값
|
29 |
True, # 'Randomize' 체크박스 컴포넌트의 불리언 값
|
|
|
30 |
api_name="/predict"
|
31 |
)
|
32 |
+
|
33 |
+
# Process results and possibly call predict multiple times if multiple images are needed
|
34 |
print(results)
|
35 |
+
return results # 실제 API 응답에 기반한 반환 구문
|
|
|
|
|
36 |
|
37 |
def infer(image_in):
|
38 |
caption = get_caption(image_in)
|
39 |
img_var = get_lcm(caption)
|
40 |
return img_var
|
41 |
|
42 |
+
# Create an Interface object with proper parameters
|
43 |
+
interface = gr.Interface(
|
44 |
+
title="ArXivGPT Image",
|
45 |
+
description="Image to Image variation, using LCM SDXL & Moondream1",
|
46 |
+
fn=infer,
|
47 |
+
inputs=gr.Image(type="filepath", label="Image input"),
|
48 |
+
outputs=gr.Image(label="Image variation")
|
49 |
+
)
|
50 |
+
|
51 |
+
# Launch the interface
|
52 |
+
interface.queue(max_size=25).launch()
|