Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,54 +1,56 @@
|
|
1 |
-
#from transformers import pipeline
|
2 |
-
#import streamlit as st
|
3 |
-
|
4 |
-
#pipe = pipeline('sentiment-analysis')
|
5 |
-
#text = st.text_area('Enter some text here!')
|
6 |
-
|
7 |
-
#if text:
|
8 |
-
# out = pipe(text)
|
9 |
-
# st.json(out)
|
10 |
-
|
11 |
-
|
12 |
from transformers import pipeline
|
|
|
13 |
import torch
|
14 |
|
15 |
device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
from transformers import pipeline
|
2 |
+
import streamlit as st
|
3 |
import torch
|
4 |
|
5 |
device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
6 |
+
pipe = pipeline('chat-response', 'liuhaotian/llava-v1.5-13b', device=device )
|
7 |
+
text = st.text_area('Enter some text here!')
|
8 |
+
|
9 |
+
if text:
|
10 |
+
out = pipe(text)
|
11 |
+
st.json(out)
|
12 |
+
|
13 |
+
|
14 |
+
# from transformers import pipeline
|
15 |
+
# import torch
|
16 |
+
|
17 |
+
# device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
18 |
+
# classifier = pipeline(
|
19 |
+
# "audio-classification", model="MIT/ast-finetuned-speech-commands-v2", device=device
|
20 |
+
# )
|
21 |
+
|
22 |
+
# from transformers.pipelines.audio_utils import ffmpeg_microphone_live
|
23 |
+
|
24 |
+
|
25 |
+
# def launch_fn(
|
26 |
+
# wake_word="marvin",
|
27 |
+
# prob_threshold=0.5,
|
28 |
+
# chunk_length_s=2.0,
|
29 |
+
# stream_chunk_s=1,
|
30 |
+
# debug=False,
|
31 |
+
# ):
|
32 |
+
# if wake_word not in classifier.model.config.label2id.keys():
|
33 |
+
# raise ValueError(
|
34 |
+
# f"Wake word {wake_word} not in set of valid class labels, pick a wake word in the set {classifier.model.config.label2id.keys()}."
|
35 |
+
# )
|
36 |
+
|
37 |
+
# sampling_rate = classifier.feature_extractor.sampling_rate
|
38 |
+
|
39 |
+
# mic = ffmpeg_microphone_live(
|
40 |
+
# sampling_rate=sampling_rate,
|
41 |
+
# chunk_length_s=chunk_length_s,
|
42 |
+
# stream_chunk_s=stream_chunk_s,
|
43 |
+
# )
|
44 |
+
|
45 |
+
# print("Listening for wake word...")
|
46 |
+
# mic_results = classifier(mic)
|
47 |
+
# for prediction in mic_results:
|
48 |
+
# prediction = prediction[0]
|
49 |
+
# if debug:
|
50 |
+
# print(prediction)
|
51 |
+
# if prediction["label"] == wake_word:
|
52 |
+
# if prediction["score"] > prob_threshold:
|
53 |
+
# return True
|
54 |
+
|
55 |
+
# launch_fn(debug=True)
|
56 |
|