Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -22,8 +22,7 @@ model = AutoModelForCausalLM.from_pretrained(
|
|
22 |
device_map='auto'
|
23 |
)
|
24 |
|
25 |
-
|
26 |
-
|
27 |
def wrap_json_in_markdown(text):
|
28 |
result = []
|
29 |
stack = []
|
@@ -184,7 +183,6 @@ def process_text_deepl(input_string, api_key):
|
|
184 |
processed_string = unicode_word_pattern.sub(process_match, input_string)
|
185 |
return processed_string
|
186 |
|
187 |
-
@spaces.GPU()
|
188 |
def process_image_and_text(image, text):
|
189 |
# Process the image and text
|
190 |
inputs = processor.process(
|
@@ -205,10 +203,10 @@ def process_image_and_text(image, text):
|
|
205 |
# Only get generated tokens; decode them to text
|
206 |
generated_tokens = output[0, inputs['input_ids'].size(1):]
|
207 |
generated_text = processor.tokenizer.decode(generated_tokens, skip_special_tokens=True)
|
208 |
-
|
209 |
-
|
210 |
|
211 |
-
return
|
212 |
|
213 |
def chatbot(image, text, history):
|
214 |
if image is None:
|
|
|
22 |
device_map='auto'
|
23 |
)
|
24 |
|
25 |
+
@spaces.GPU()
|
|
|
26 |
def wrap_json_in_markdown(text):
|
27 |
result = []
|
28 |
stack = []
|
|
|
183 |
processed_string = unicode_word_pattern.sub(process_match, input_string)
|
184 |
return processed_string
|
185 |
|
|
|
186 |
def process_image_and_text(image, text):
|
187 |
# Process the image and text
|
188 |
inputs = processor.process(
|
|
|
203 |
# Only get generated tokens; decode them to text
|
204 |
generated_tokens = output[0, inputs['input_ids'].size(1):]
|
205 |
generated_text = processor.tokenizer.decode(generated_tokens, skip_special_tokens=True)
|
206 |
+
generated_text_w_unicode_mdn = process_text_deepl(generated_text, "a5b1749b-7112-4c2d-81a3-33ea18478bb4:fx")
|
207 |
+
generated_text_w_json_wrapper = wrap_json_in_markdown(generated_text_w_unicode_mdn)
|
208 |
|
209 |
+
return generated_text_w_json_wrapper
|
210 |
|
211 |
def chatbot(image, text, history):
|
212 |
if image is None:
|