pizb commited on
Commit
1768ec2
ยท
1 Parent(s): 1e6ccdc

feat: add category selection

Browse files
Files changed (1) hide show
  1. demo.py +11 -3
demo.py CHANGED
@@ -28,12 +28,12 @@ def translate_en_to_ko(text):
28
  return f"๋ฒˆ์—ญ ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ: {str(e)}"
29
 
30
 
31
- def critic_image(image, language):
32
  img_base64 = encode_image_to_base64(image)
33
  payload = {
34
  "input": {
35
  "max_new_tokens": 512,
36
- "category": "General Visual Analysis",
37
  "image": img_base64
38
  }
39
  }
@@ -55,11 +55,19 @@ def critic_image(image, language):
55
  return analysis_result # ์˜์–ด ๊ทธ๋Œ€๋กœ ๋ฐ˜ํ™˜
56
 
57
 
 
 
 
 
 
 
 
58
  demo = gr.Interface(
59
  fn=critic_image,
60
  inputs=[
61
  gr.Image(type="pil"),
62
- gr.Radio(choices=["EN", "KO"], label="Select Language", value="EN")
 
63
  ],
64
  outputs="text",
65
  title="Gemmarte",
 
28
  return f"๋ฒˆ์—ญ ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ: {str(e)}"
29
 
30
 
31
+ def critic_image(image, language, category):
32
  img_base64 = encode_image_to_base64(image)
33
  payload = {
34
  "input": {
35
  "max_new_tokens": 512,
36
+ "category": category,
37
  "image": img_base64
38
  }
39
  }
 
55
  return analysis_result # ์˜์–ด ๊ทธ๋Œ€๋กœ ๋ฐ˜ํ™˜
56
 
57
 
58
+ categories = [
59
+ 'General Visual Analysis', 'Form and Shape', 'Symbolism and Iconography',
60
+ 'Composition', 'Color Palette', 'Light and Shadow', 'Texture',
61
+ 'Movement and Gesture', 'Line Quality', 'Perspective', 'Scale and Proportion'
62
+ ]
63
+
64
+
65
  demo = gr.Interface(
66
  fn=critic_image,
67
  inputs=[
68
  gr.Image(type="pil"),
69
+ gr.Radio(choices=["EN", "KO"], label="Select Language", value="EN"),
70
+ gr.Dropdown(choices=categories, label="Select Category", value="General Visual Analysis")
71
  ],
72
  outputs="text",
73
  title="Gemmarte",