snowkylin commited on
Commit
df18092
·
1 Parent(s): 1c4a5e2

update description and ui

Browse files
Files changed (1) hide show
  1. app.py +38 -20
app.py CHANGED
@@ -13,7 +13,7 @@ default_api_model = "google/gemma-3-27b-it"
13
 
14
  model_id = "google/gemma-3-4b-it"
15
  huggingface_spaces = "HUGGINGFACE_SPACES" in os.environ and os.environ['HUGGINGFACE_SPACES'] == "1"
16
- local = "local" in os.environ and os.environ['LOCAL'] == "1"
17
 
18
  if huggingface_spaces or local:
19
  from transformers import AutoProcessor, Gemma3ForConditionalGeneration, TextIteratorStreamer
@@ -47,8 +47,18 @@ lang_store = {
47
  "default_description": "",
48
  "additional_description": "Character description (optional)",
49
  "description_placeholder": "Information that is not shown in the reference sheet, such as the character's name, personality, past stories and habit of saying.",
 
50
  "more_imgs": "More reference images of the character (optional)",
51
- "title": """# RefSheet Chat -- Chat with a character via reference sheet!""",
 
 
 
 
 
 
 
 
 
52
  "upload": "Upload the reference sheet of the character here",
53
  "prompt": "You are the character in the image, use %s. Use a conversational, oral tone. Do not mention the reference images directly. Start without confirmation.",
54
  "additional_info_prompt": "Additional info: ",
@@ -73,20 +83,30 @@ lang_store = {
73
  "ru": "Russian",
74
  "ar": "Arabic",
75
  "default_language": "en",
76
- "author": "<p align='center'>Developed by <a href='https://github.com/snowkylin'>snowkylin</a>, powered by <a href='https://blog.google/technology/developers/gemma-3/'>Gemma 3</a></p>"
77
  },
78
  "zh": {
79
  "confirm": "确认",
80
  "default_description": "",
81
- "additional_description": "角色描述(可选)",
82
- "description_placeholder": "未在设定图中包含的角色信息,如角色姓名、性格、言语习惯、过往经历等。",
83
- "more_imgs": "更多角色参考图(可选,可上传多张)",
84
- "title": """# RefSheet Chat——与设定图中的角色聊天!""",
 
 
 
 
 
 
 
 
 
 
85
  "upload": "在这里上传角色设定图",
86
  "prompt": "你的身份是图中的角色,使用%s。使用聊天的,口语化的方式表达。不在回复中直接提及参考图。无需确认。",
87
  "additional_info_prompt": "补充信息:",
88
  "additional_reference_images_prompt": "该角色的更多参考图:",
89
- "description": "角色描述",
90
  "more_options": "更多选项",
91
  "method": "方法",
92
  "base_url": "API ���址",
@@ -106,7 +126,7 @@ lang_store = {
106
  "ru": "俄语",
107
  "ar": "阿拉伯语",
108
  "default_language": "zh",
109
- "author": "<p align='center'>由 <a href='https://github.com/snowkylin'>snowkylin</a> 开发,由 <a href='https://blog.google/technology/developers/gemma-3/'>Gemma 3</a> 驱动</p>"
110
  },
111
  }
112
 
@@ -208,7 +228,7 @@ def set_default_character_language(request: gr.Request):
208
 
209
  with gr.Blocks(title="Chat with a character via reference sheet!") as demo:
210
  with Translate(lang_store) as lang:
211
- gr.Markdown(_("title"))
212
  img = gr.Image(type="filepath", value=default_img, label=_("upload"), render=False)
213
  description = gr.TextArea(
214
  value=_("default_description"),
@@ -238,7 +258,7 @@ with gr.Blocks(title="Chat with a character via reference sheet!") as demo:
238
  file_types=["image"],
239
  render=False
240
  )
241
- confirm_btn = gr.Button(_("confirm"), render=False)
242
  chatbot = gr.Chatbot(height=600, type='messages', label=_("chatbox"), render=False)
243
  engine = gr.Radio(
244
  choices=[
@@ -256,22 +276,18 @@ with gr.Blocks(title="Chat with a character via reference sheet!") as demo:
256
  with gr.Row():
257
  with gr.Column(scale=4):
258
  img.render()
 
 
 
 
 
259
  if local or huggingface_spaces:
260
- with gr.Tab(_("description")):
261
- description.render()
262
- character_language.render()
263
- more_imgs.render()
264
- confirm_btn.render()
265
  with gr.Tab(_("more_options")):
266
  engine.render()
267
  base_url.render()
268
  api_model.render()
269
  api_key.render()
270
  else:
271
- description.render()
272
- character_language.render()
273
- more_imgs.render()
274
- confirm_btn.render()
275
  engine.visible = False
276
  base_url.visible = False
277
  api_model.visible = False
@@ -280,6 +296,8 @@ with gr.Blocks(title="Chat with a character via reference sheet!") as demo:
280
  base_url.render()
281
  api_model.render()
282
  api_key.render()
 
 
283
  with gr.Column(scale=6):
284
  chat = gr.ChatInterface(
285
  response,
 
13
 
14
  model_id = "google/gemma-3-4b-it"
15
  huggingface_spaces = "HUGGINGFACE_SPACES" in os.environ and os.environ['HUGGINGFACE_SPACES'] == "1"
16
+ local = "LOCAL" in os.environ and os.environ['LOCAL'] == "1"
17
 
18
  if huggingface_spaces or local:
19
  from transformers import AutoProcessor, Gemma3ForConditionalGeneration, TextIteratorStreamer
 
47
  "default_description": "",
48
  "additional_description": "Character description (optional)",
49
  "description_placeholder": "Information that is not shown in the reference sheet, such as the character's name, personality, past stories and habit of saying.",
50
+ "more_imgs_tab": "More reference images",
51
  "more_imgs": "More reference images of the character (optional)",
52
+ "title": """
53
+ <h1>RefSheet Chat -- Chat with a character via reference sheet!
54
+ <span style='float: right'><iframe src="https://ghbtns.com/github-btn.html?user=snowkylin&repo=refsheet_chat&type=star&count=true" frameborder="0" scrolling="0" width="80" height="20" title="GitHub"></span></iframe>
55
+ </h1>
56
+
57
+ Upload a [reference sheet](https://www.google.com/search?q=reference+sheet+art) of a character, then RefSheet Chat will try to understand the character through the reference sheet, and talk to you as that character.
58
+
59
+ You can also add text descriptions and provide more reference pictures to help RefSheet Chat understand the character more accurately. The content you provide is only used for RefSheet Chat to understand the character and talk to you, and will not be used for other purposes. You can [run the program on your own computer](https://github.com/snowkylin/refsheet_chat) without Internet to ensure privacy.
60
+
61
+ How will RefSheet Chat understand your character? Have a try!""",
62
  "upload": "Upload the reference sheet of the character here",
63
  "prompt": "You are the character in the image, use %s. Use a conversational, oral tone. Do not mention the reference images directly. Start without confirmation.",
64
  "additional_info_prompt": "Additional info: ",
 
83
  "ru": "Russian",
84
  "ar": "Arabic",
85
  "default_language": "en",
86
+ "author": "<p align='center'>Developed by <a href='https://github.com/snowkylin'>snowkylin</a>, powered by <a href='https://blog.google/technology/developers/gemma-3/'>Gemma 3</a> open model</p>"
87
  },
88
  "zh": {
89
  "confirm": "确认",
90
  "default_description": "",
91
+ "additional_description": "角色文字描述(可选)",
92
+ "description_placeholder": "未在设定图中包含的角色信息,可以包括角色姓名、性格、言语习惯、过往经历等。",
93
+ "more_imgs_tab": "额外角色参考图",
94
+ "more_imgs": "额外角色参考图(可选,可上传多张)",
95
+ "title": """
96
+ <h1>RefSheet Chat——与设定图中的角色聊天!
97
+ <span style='float: right'><iframe src="https://ghbtns.com/github-btn.html?user=snowkylin&repo=refsheet_chat&type=star&count=true" frameborder="0" scrolling="0" width="80" height="20" title="GitHub"></span></iframe>
98
+ </h1>
99
+
100
+ “一图胜千言”——上传一张[角色设定图](https://www.bing.com/images/search?q=%E8%A7%92%E8%89%B2%E8%AE%BE%E5%AE%9A%E5%9B%BE)(reference sheet),RefSheet Chat 即会理解和“脑补”设定图中的信息,并以这位角色的身份与您对话。
101
+
102
+ 您也可以补充文字描述以及提供更多的参考图,以帮助 RefSheet Chat 更准确地理解角色。您提供的内容仅用于 RefSheet Chat 理解角色并与您对话,不会另做他用。您可以[在自己的电脑上离线运行该程序](https://github.com/snowkylin/refsheet_chat)以确保隐私。
103
+
104
+ RefSheet Chat 将如何理解您的角色呢?试试看!""",
105
  "upload": "在这里上传角色设定图",
106
  "prompt": "你的身份是图中的角色,使用%s。使用聊天的,口语化的方式表达。不在回复中直接提及参考图。无需确认。",
107
  "additional_info_prompt": "补充信息:",
108
  "additional_reference_images_prompt": "该角色的更多参考图:",
109
+ "description": "额外角色设定",
110
  "more_options": "更多选项",
111
  "method": "方法",
112
  "base_url": "API ���址",
 
126
  "ru": "俄语",
127
  "ar": "阿拉伯语",
128
  "default_language": "zh",
129
+ "author": """<p align='center'>由 <a href='https://github.com/snowkylin'>snowkylin</a> 开发,由开源的 <a href='https://blog.google/technology/developers/gemma-3/'>Gemma 3</a> 驱动</p>"""
130
  },
131
  }
132
 
 
228
 
229
  with gr.Blocks(title="Chat with a character via reference sheet!") as demo:
230
  with Translate(lang_store) as lang:
231
+ gr.Markdown(_("title"), sanitize_html=False)
232
  img = gr.Image(type="filepath", value=default_img, label=_("upload"), render=False)
233
  description = gr.TextArea(
234
  value=_("default_description"),
 
258
  file_types=["image"],
259
  render=False
260
  )
261
+ confirm_btn = gr.Button(_("confirm"), render=False, variant='primary')
262
  chatbot = gr.Chatbot(height=600, type='messages', label=_("chatbox"), render=False)
263
  engine = gr.Radio(
264
  choices=[
 
276
  with gr.Row():
277
  with gr.Column(scale=4):
278
  img.render()
279
+ with gr.Tab(_("description")):
280
+ description.render()
281
+ character_language.render()
282
+ with gr.Tab(_("more_imgs_tab")):
283
+ more_imgs.render()
284
  if local or huggingface_spaces:
 
 
 
 
 
285
  with gr.Tab(_("more_options")):
286
  engine.render()
287
  base_url.render()
288
  api_model.render()
289
  api_key.render()
290
  else:
 
 
 
 
291
  engine.visible = False
292
  base_url.visible = False
293
  api_model.visible = False
 
296
  base_url.render()
297
  api_model.render()
298
  api_key.render()
299
+
300
+ confirm_btn.render()
301
  with gr.Column(scale=6):
302
  chat = gr.ChatInterface(
303
  response,