Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,11 +7,18 @@ Original file is located at
|
|
7 |
https://colab.research.google.com/drive/1OQvi3I_q3WfavYBpjovCYfv2SPYt__pF
|
8 |
"""
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
import json
|
11 |
import gradio as gr
|
12 |
import tensorflow as tf
|
13 |
from tensorflow.keras.models import load_model
|
14 |
from tensorflow.keras.preprocessing.text import tokenizer_from_json
|
|
|
15 |
|
16 |
# Load the pre-trained model and tokenizer
|
17 |
model = tf.keras.models.load_model('baseline.h5')
|
@@ -35,16 +42,20 @@ def classify_comment(comment):
|
|
35 |
predictions = model.predict(comment_sequence)[0]
|
36 |
results = dict(zip(labels, predictions))
|
37 |
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
40 |
|
41 |
-
|
|
|
|
|
42 |
|
43 |
-
# Create the Gradio interface with an improved layout
|
44 |
iface = gr.Interface(
|
45 |
fn=classify_comment,
|
46 |
-
inputs=
|
47 |
-
outputs=
|
48 |
live=True # Set to True for live updates without needing to restart the server
|
49 |
)
|
50 |
|
|
|
7 |
https://colab.research.google.com/drive/1OQvi3I_q3WfavYBpjovCYfv2SPYt__pF
|
8 |
"""
|
9 |
|
10 |
+
"""gradio_app.py
|
11 |
+
Automatically generated by Colaboratory.
|
12 |
+
Original file is located at
|
13 |
+
https://colab.research.google.com/drive/1OQvi3I_q3WfavYBpjovCYfv2SPYt__pF
|
14 |
+
"""
|
15 |
+
|
16 |
import json
|
17 |
import gradio as gr
|
18 |
import tensorflow as tf
|
19 |
from tensorflow.keras.models import load_model
|
20 |
from tensorflow.keras.preprocessing.text import tokenizer_from_json
|
21 |
+
import tensorflow_addons as tfa
|
22 |
|
23 |
# Load the pre-trained model and tokenizer
|
24 |
model = tf.keras.models.load_model('baseline.h5')
|
|
|
42 |
predictions = model.predict(comment_sequence)[0]
|
43 |
results = dict(zip(labels, predictions))
|
44 |
|
45 |
+
max_value = max(results.values())
|
46 |
+
|
47 |
+
max_keys = [key for key, value in results.items() if value == max_value]
|
48 |
+
|
49 |
+
return max_keys[0].capitalize()
|
50 |
|
51 |
+
# Create the Gradio interface
|
52 |
+
comment_input = gr.inputs.Textbox(label="Enter your comment here")
|
53 |
+
output_text = gr.outputs.Textbox(label="Classification Results")
|
54 |
|
|
|
55 |
iface = gr.Interface(
|
56 |
fn=classify_comment,
|
57 |
+
inputs=comment_input,
|
58 |
+
outputs=output_text,
|
59 |
live=True # Set to True for live updates without needing to restart the server
|
60 |
)
|
61 |
|