Spaces:
Runtime error
Runtime error
the-future-dev
commited on
Commit
•
beccfdf
1
Parent(s):
602adb2
first commit
Browse files
app.py
CHANGED
@@ -15,7 +15,7 @@ if uploaded_file is not None:
|
|
15 |
if st.button('Classify'):
|
16 |
st.write(f"User: {prompt}")
|
17 |
with st.spinner('Processing...'):
|
18 |
-
label = kosmos.single_image_classification(image, prompt,
|
19 |
st.write(f"Model: {label}")
|
20 |
except Exception as e:
|
21 |
st.error(f"An error occurred: {e}")
|
|
|
15 |
if st.button('Classify'):
|
16 |
st.write(f"User: {prompt}")
|
17 |
with st.spinner('Processing...'):
|
18 |
+
label = kosmos.single_image_classification(image, prompt, 150)
|
19 |
st.write(f"Model: {label}")
|
20 |
except Exception as e:
|
21 |
st.error(f"An error occurred: {e}")
|
kosmos.py
CHANGED
@@ -19,8 +19,8 @@ def single_image_classification(image, prompt="", max_new_tokens=30):
|
|
19 |
use_cache=True,
|
20 |
max_new_tokens=max_new_tokens,
|
21 |
)
|
22 |
-
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=
|
23 |
|
24 |
-
|
25 |
-
print("ROBOT:",
|
26 |
return processed_text
|
|
|
19 |
use_cache=True,
|
20 |
max_new_tokens=max_new_tokens,
|
21 |
)
|
22 |
+
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
23 |
|
24 |
+
caption, entities = processor.post_process_generation(generated_text)
|
25 |
+
print("ROBOT:", caption)
|
26 |
return processed_text
|