Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,30 +1,24 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
|
| 9 |
-
st.write("Classification for 6 emotions: sadness, joy, love, anger, fear, surprise")
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
# Perform text classification on the input text
|
| 17 |
-
results = classifier(text)[0]
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
st.write("Text:", text)
|
| 29 |
-
st.write("Label:", max_label)
|
| 30 |
-
st.write("Score:", max_score)
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
+
# 加载 Visual Question Answering 模型
|
| 5 |
+
vqa_pipeline = pipeline("text2text-generation", model="mrm8488/t5-base-finetuned-vqa")
|
| 6 |
|
| 7 |
+
# 加载文本到语音模型
|
| 8 |
+
text_to_speech_pipeline = pipeline("text-to-speech", model="tts_model_name")
|
|
|
|
| 9 |
|
| 10 |
+
def main():
|
| 11 |
+
st.title("Visual Question Answering with Text-to-Speech")
|
| 12 |
|
| 13 |
+
image_path = st.text_input("Enter image path:")
|
| 14 |
+
question = st.text_input("Enter your question:")
|
|
|
|
|
|
|
| 15 |
|
| 16 |
+
if st.button("Get Answer"):
|
| 17 |
+
answer = vqa_pipeline(question, image_path)[0]['generated_text']
|
| 18 |
+
audio_data = text_to_speech_pipeline(answer)
|
| 19 |
|
| 20 |
+
st.write("Answer:", answer)
|
| 21 |
+
st.audio(audio_data[0]["audio"], format='audio/wav')
|
| 22 |
+
|
| 23 |
+
if __name__ == '__main__':
|
| 24 |
+
main()
|
|
|
|
|
|
|
|
|