Spaces:
Sleeping
Sleeping
Commit
·
473ba60
1
Parent(s):
b7b4f4c
Making changes on image classifucation
Browse files
app.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
'''Imports'''
|
2 |
import tensorflow as tf
|
3 |
-
import requests
|
4 |
from transformers import pipeline
|
5 |
import gradio as gr
|
6 |
|
@@ -8,8 +8,8 @@ import gradio as gr
|
|
8 |
inception_net = tf.keras.applications.MobileNetV2()
|
9 |
|
10 |
'''Making request and set database'''
|
11 |
-
response = requests.get("https://git.io/JJkYN")
|
12 |
-
tags = response.text.split("\n")
|
13 |
|
14 |
'''Define model and classify pipelines'''
|
15 |
trans = pipeline("automatic-speech-recognition", model="facebook/wav2vec2-large-xlsr-53-spanish")
|
@@ -17,10 +17,13 @@ classify = pipeline("text-classification", model="pysentimiento/robertuito-senti
|
|
17 |
|
18 |
'''Define functions for demo'''
|
19 |
def classify_image(inp):
|
20 |
-
inp = inp.reshape((-1,224,224,3))
|
21 |
inp = tf.keras.applications.mobilenet_v2.preprocess_input(inp)
|
22 |
-
prediction = inception_net.predict(inp).
|
23 |
-
|
|
|
|
|
|
|
24 |
return confidences
|
25 |
|
26 |
def audio_to_text(audio):
|
@@ -34,8 +37,6 @@ def text_to_sentiment(text):
|
|
34 |
demo = gr.Blocks()
|
35 |
|
36 |
'''Making demo'''
|
37 |
-
demo = gr.Blocks()
|
38 |
-
|
39 |
with demo:
|
40 |
gr.Markdown("Second Demo with Blocks")
|
41 |
with gr.Tabs():
|
|
|
1 |
'''Imports'''
|
2 |
import tensorflow as tf
|
3 |
+
#import requests
|
4 |
from transformers import pipeline
|
5 |
import gradio as gr
|
6 |
|
|
|
8 |
inception_net = tf.keras.applications.MobileNetV2()
|
9 |
|
10 |
'''Making request and set database'''
|
11 |
+
#response = requests.get("https://git.io/JJkYN")
|
12 |
+
#tags = response.text.split("\n")
|
13 |
|
14 |
'''Define model and classify pipelines'''
|
15 |
trans = pipeline("automatic-speech-recognition", model="facebook/wav2vec2-large-xlsr-53-spanish")
|
|
|
17 |
|
18 |
'''Define functions for demo'''
|
19 |
def classify_image(inp):
|
20 |
+
inp = inp.reshape((-1, 224, 224, 3))
|
21 |
inp = tf.keras.applications.mobilenet_v2.preprocess_input(inp)
|
22 |
+
prediction = inception_net.predict(inp).reshape(1,1000)
|
23 |
+
pred_scores = tf.keras.applications.mobilenet_v2.decode_predictions(prediction, top=100)
|
24 |
+
#prediction = inception_net.predict(inp).flatten()
|
25 |
+
confidences = {f'{pred_scores[0][i][1]}': float(pred_scores[0][i][2]) for i in range(100)}
|
26 |
+
#confidences = {tags[i]: float(prediction[i]) for i in range(1000)}
|
27 |
return confidences
|
28 |
|
29 |
def audio_to_text(audio):
|
|
|
37 |
demo = gr.Blocks()
|
38 |
|
39 |
'''Making demo'''
|
|
|
|
|
40 |
with demo:
|
41 |
gr.Markdown("Second Demo with Blocks")
|
42 |
with gr.Tabs():
|