oldgarden21 commited on
Commit
dcea58a
ยท
verified ยท
1 Parent(s): 082e33e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -21
app.py CHANGED
@@ -1,25 +1,13 @@
1
  import gradio as gr
2
- from huggingface_hub import hf_hub_download
3
- import tensorflow as tf
4
 
5
- # Hugging Face Hub์—์„œ ๋ชจ๋ธ ํŒŒ์ผ ๋‹ค์šด๋กœ๋“œ
6
- model_path = hf_hub_download(repo_id="safoinme/zenml-mnist", filename="model.h5")
7
 
8
- # ๋‹ค์šด๋กœ๋“œํ•œ ๋ชจ๋ธ ํŒŒ์ผ๋กœ๋ถ€ํ„ฐ Keras ๋ชจ๋ธ ๋กœ๋“œ
9
- model = tf.keras.models.load_model(model_path)
 
10
 
11
- def recognize_digit(img):
12
- # ์ด๋ฏธ์ง€ ์ „์ฒ˜๋ฆฌ
13
- img = img.reshape(1, 28, 28, 1) / 255.0
14
- # ๋ชจ๋ธ ์˜ˆ์ธก
15
- prediction = model.predict(img).argmax()
16
- return str(prediction)
17
-
18
- # Gradio ์ธํ„ฐํŽ˜์ด์Šค ์„ค์ •
19
- iface = gr.Interface(fn=recognize_digit,
20
- inputs=gr.inputs.Image(shape=(28,28), image_mode='L', invert_colors=True, source="canvas"),
21
- outputs="text",
22
- title="MNIST Digit Recognizer",
23
- description="Draw a digit on the canvas and click 'Submit' to recognize it. Model trained on the MNIST dataset.")
24
- # ์ธํ„ฐํŽ˜์ด์Šค ์‹คํ–‰
25
- iface.launch()
 
1
  import gradio as gr
2
+ from transformers import pipeline
 
3
 
4
+ # ๊ฐ์ • ๋ถ„์„ ํŒŒ์ดํ”„๋ผ์ธ ์ดˆ๊ธฐํ™”
5
+ sentiment_analysis = pipeline("sentiment-analysis")
6
 
7
+ def predict_sentiment(text):
8
+ result = sentiment_analysis(text)
9
+ return result[0]
10
 
11
+ # Gradio ์ธํ„ฐํŽ˜์ด์Šค ์„ค์ • ๋ฐ ์•ฑ ์‹คํ–‰
12
+ iface = gr.Interface(fn=predict_sentiment, inputs="text", outputs="text", title="Simple Sentiment Analysis")
13
+ iface.launch()