arxivgpt kim commited on
Commit
ce2ed82
·
verified ·
1 Parent(s): 2f1fdee

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -22
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
- results = client.predict(
7
- prompt, # existing parameters
8
- num_images=4, # New parameter to request 4 images. This parameter may be different for the actual API.
 
 
 
 
 
9
  )
10
- # Print and return the results assuming it contains 4 images
11
  print(results)
12
- return results[:4] # Return first 4 images in case the API returns more
13
 
14
  def get_lcm(prompt):
15
  client = Client("https://latent-consistency-lcm-lora-for-sdxl.hf.space/")
16
- # 'client.predict' 호출에서 들여쓰기가 올바른지 확인해야 합니다.
 
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
- # 결과 처리 및 여러 이미지가 필요한 경우 여러 번 'predict'를 호출할 수 있습니다.
 
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
- gr.Interface(
38
- title = "ArXivGPT Image",
39
- description = "Image to Image variation, using LCM SDXL & Moondream1",
40
- fn = infer,
41
- inputs = [
42
- gr.Image(type="filepath", label="Image input")
43
- ],
44
- outputs = [
45
- gr.Image(label="Image variation")
46
- ]
47
- ).queue(max_size=25).launch()
 
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()