arxivgpt kim commited on
Commit
47c5f9a
·
verified ·
1 Parent(s): 846fc12

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -32
app.py CHANGED
@@ -3,42 +3,41 @@ from gradio_client import Client
3
 
4
  def get_caption(image_in):
5
  client = Client("https://vikhyatk-moondream1.hf.space/")
6
- caption = client.predict(
7
- image_in, # 'image_in' 이미지 파일의 경로입니다.
8
- "Describe the image", # 'Describe the image' 모델에 제출되는 문장입니다.
9
- api_name="/answer_question"
10
  )
11
- print(caption)
12
- return caption # caption 변수는 이미지 설명 문자열을 담고 있습니다.
13
 
14
-
15
- def get_lcm(caption):
16
- client = Client("현재 사용할 이미지 생성 API URL")
17
- # 적절한 이미지 생성 API 파라미터를 전달하여 결과 이미지를 요청합니다.
18
- results = client.predict(
19
- prompt=caption, # 이미지 설명을 생성 API에 전달합니다.
20
- number_of_images=1, # 생성하려는 이미지 개수입니다. 필요한 경우 값을 변경하세요.
21
- api_name="/generate_image" # API 엔드포인트입니다. 해당 API에 맞게 수정하세요.
 
22
  )
23
- # API에서 반환된 이미지들을 처리합니다. 반환 타입 및 방법에 대해서는 API 문서를 확인하세요.
24
- return results # 이 부분은 생성된 이미지를 반환하는 것을 의미합니다.
25
-
26
  def infer(image_in):
27
  caption = get_caption(image_in)
28
- # 부분은 get_lcm 함수가 올바른 이미지를 생성하고 반환하도록 구현해야 합니다.
29
- # img_var = get_lcm(caption)
30
-
31
- # 예제에서는 단순히 이미지 경로를 반환하도록 생략합니다.
32
- return image_in # 실제로는 get_lcm 함수의 결과를 반환해야 합니다.
33
 
34
- # Create an Interface object with proper parameters
35
- interface = gr.Interface(
36
- title="ArXivGPT Image",
37
- description="Image to Image variation, using LCM SDXL & Moondream1",
38
- fn=infer,
39
- inputs=gr.Image(type="filepath", label="Image input"),
40
- outputs=gr.Image(label="Image variation")
41
- )
 
 
 
42
 
43
- # Launch the interface
44
- interface.queue(max_size=25).launch()
 
3
 
4
  def get_caption(image_in):
5
  client = Client("https://vikhyatk-moondream1.hf.space/")
6
+ result = client.predict(
7
+ image_in, # filepath in 'image' Image component
8
+ "Describe the image", # str in 'Question' Textbox component
9
+ api_name="/answer_question"
10
  )
11
+ print(result)
12
+ return result
13
 
14
+ def get_lcm(prompt):
15
+ client = Client("https://latent-consistency-lcm-lora-for-sdxl.hf.space/")
16
+ result = client.predict(
17
+ prompt, # str in 'parameter_5' Textbox component
18
+ 0.3, # float (numeric value between 0.0 and 5) in 'Guidance' Slider component
19
+ 8, # float (numeric value between 2 and 10) in 'Steps' Slider component
20
+ 0, # float (numeric value between 0 and 12013012031030) in 'Seed' Slider component
21
+ True, # bool in 'Randomize' Checkbox component
22
+ api_name="/predict"
23
  )
24
+ print(result)
25
+ return result[0]
26
+
27
  def infer(image_in):
28
  caption = get_caption(image_in)
29
+ img_var = get_lcm(caption)
30
+ return img_var
 
 
 
31
 
32
+ gr.Interface(
33
+ title = "ArXivGPT Image",
34
+ description = "Image to Image variation, using LCM SDXL & Moondream1",
35
+ fn = infer,
36
+ inputs = [
37
+ gr.Image(type="filepath", label="Image input")
38
+ ],
39
+ outputs = [
40
+ gr.Image(label="LCM Image variation")
41
+ ]
42
+ ).queue(max_size=25).launch()
43