Spaces:
Runtime error
Runtime error
abdfajar707
commited on
Commit
•
6bd9bdb
1
Parent(s):
4197891
Update app.py
Browse files
app.py
CHANGED
@@ -47,7 +47,7 @@ form_radio = {
|
|
47 |
#'value': 'Beam Search',
|
48 |
'value': 'Sampling',
|
49 |
'interactive': True,
|
50 |
-
'label': 'Decode
|
51 |
}
|
52 |
# Beam Form
|
53 |
num_beams_slider = {
|
@@ -56,7 +56,7 @@ num_beams_slider = {
|
|
56 |
'value': 3,
|
57 |
'step': 1,
|
58 |
'interactive': True,
|
59 |
-
'label': '
|
60 |
}
|
61 |
repetition_penalty_slider = {
|
62 |
'minimum': 0,
|
@@ -80,7 +80,7 @@ max_new_tokens_slider = {
|
|
80 |
'value': 1024,
|
81 |
'step': 1,
|
82 |
'interactive': True,
|
83 |
-
'label': '
|
84 |
}
|
85 |
|
86 |
top_p_slider = {
|
@@ -138,7 +138,7 @@ def chat(img, msgs, ctx, params=None, vision_hidden_states=None):
|
|
138 |
if params is None:
|
139 |
params = default_params
|
140 |
if img is None:
|
141 |
-
yield "
|
142 |
else:
|
143 |
try:
|
144 |
image = img.convert('RGB')
|
@@ -169,7 +169,7 @@ def upload_img(image, _chatbot, _app_session):
|
|
169 |
_app_session['sts']=None
|
170 |
_app_session['ctx']=[]
|
171 |
_app_session['img']=image
|
172 |
-
_chatbot.append(('', '
|
173 |
return _chatbot, _app_session
|
174 |
|
175 |
|
@@ -177,7 +177,7 @@ def respond(_chat_bot, _app_cfg, params_form, num_beams, repetition_penalty, rep
|
|
177 |
_question = _chat_bot[-1][0]
|
178 |
print('<Question>:', _question)
|
179 |
if _app_cfg.get('ctx', None) is None:
|
180 |
-
_chat_bot[-1][1] = '
|
181 |
yield (_chat_bot, _app_cfg)
|
182 |
else:
|
183 |
_context = _app_cfg['ctx'].copy()
|
@@ -256,9 +256,9 @@ with gr.Blocks() as demo:
|
|
256 |
clear = create_component({'value': 'Clear'}, comp='Button')
|
257 |
with gr.Column(scale=3, min_width=500):
|
258 |
app_session = gr.State({'sts':None,'ctx':None,'img':None})
|
259 |
-
bt_pic = gr.Image(label="
|
260 |
chat_bot = gr.Chatbot(label=f"Chat with {model_name}")
|
261 |
-
txt_message = gr.Textbox(label="
|
262 |
|
263 |
clear.click(
|
264 |
clear_button_clicked,
|
|
|
47 |
#'value': 'Beam Search',
|
48 |
'value': 'Sampling',
|
49 |
'interactive': True,
|
50 |
+
'label': 'Tipe Decode'
|
51 |
}
|
52 |
# Beam Form
|
53 |
num_beams_slider = {
|
|
|
56 |
'value': 3,
|
57 |
'step': 1,
|
58 |
'interactive': True,
|
59 |
+
'label': 'Jumlah Beams'
|
60 |
}
|
61 |
repetition_penalty_slider = {
|
62 |
'minimum': 0,
|
|
|
80 |
'value': 1024,
|
81 |
'step': 1,
|
82 |
'interactive': True,
|
83 |
+
'label': 'Maks Token Baru'
|
84 |
}
|
85 |
|
86 |
top_p_slider = {
|
|
|
138 |
if params is None:
|
139 |
params = default_params
|
140 |
if img is None:
|
141 |
+
yield "Kesalaham, tidak berhasil mengunggah gambar"
|
142 |
else:
|
143 |
try:
|
144 |
image = img.convert('RGB')
|
|
|
169 |
_app_session['sts']=None
|
170 |
_app_session['ctx']=[]
|
171 |
_app_session['img']=image
|
172 |
+
_chatbot.append(('', 'Gambar sudah berhasil diunggah, silakan tuliskan pertanyaan anda untuk memulai percakapan'))
|
173 |
return _chatbot, _app_session
|
174 |
|
175 |
|
|
|
177 |
_question = _chat_bot[-1][0]
|
178 |
print('<Question>:', _question)
|
179 |
if _app_cfg.get('ctx', None) is None:
|
180 |
+
_chat_bot[-1][1] = 'Silakan unggal gambar untuk memulai'
|
181 |
yield (_chat_bot, _app_cfg)
|
182 |
else:
|
183 |
_context = _app_cfg['ctx'].copy()
|
|
|
256 |
clear = create_component({'value': 'Clear'}, comp='Button')
|
257 |
with gr.Column(scale=3, min_width=500):
|
258 |
app_session = gr.State({'sts':None,'ctx':None,'img':None})
|
259 |
+
bt_pic = gr.Image(label="Unggah gambar untuk memulai")
|
260 |
chat_bot = gr.Chatbot(label=f"Chat with {model_name}")
|
261 |
+
txt_message = gr.Textbox(label="Masukkan Teks")
|
262 |
|
263 |
clear.click(
|
264 |
clear_button_clicked,
|