Haticece commited on
Commit
3a020f7
·
verified ·
1 Parent(s): b68be92

Upload moodify_py.py

Browse files
Files changed (1) hide show
  1. moodify_py.py +61 -0
moodify_py.py ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """Moodify.py
3
+
4
+ Automatically generated by Colab.
5
+
6
+ Original file is located at
7
+ https://colab.research.google.com/drive/1VpLXuEmWDVSNDSPi9xAbZqJ41OkvoHJ0
8
+ """
9
+
10
+ !pip install transformers gradio
11
+
12
+ import torch
13
+ print(torch.cuda.is_available()) # True dönerse GPU kullanıma hazırdır
14
+
15
+ from transformers import pipeline
16
+ import gradio as gr
17
+
18
+ # Hugging Face modelini yükleyin
19
+ sentiment_model = pipeline("sentiment-analysis")
20
+
21
+ # Modeli çalıştıracak bir fonksiyon tanımlayın
22
+ def analyze_sentiment(text):
23
+ result = sentiment_model(text)[0]
24
+ label = result['label']
25
+ score = result['score']
26
+ return f"Sentiment: {label} (Confidence: {score:.2f})"
27
+
28
+ # Gradio arayüzü
29
+ interface = gr.Interface(
30
+ fn=analyze_sentiment,
31
+ inputs=gr.Textbox(label="Enter Text"),
32
+ outputs=gr.Textbox(label="Sentiment Analysis Result")
33
+ )
34
+
35
+ # Arayüzü başlatın
36
+ interface.launch(share=True)
37
+
38
+ !pip install transformers gradio
39
+
40
+ from transformers import pipeline
41
+ import gradio as gr
42
+
43
+ # Hugging Face modelini yükleyin
44
+ sentiment_model = pipeline("sentiment-analysis")
45
+
46
+ # Modeli çalıştıracak bir fonksiyon tanımlayın
47
+ def analyze_sentiment(text):
48
+ result = sentiment_model(text)[0]
49
+ label = result['label']
50
+ score = result['score']
51
+ return f"Sentiment: {label} (Confidence: {score:.2f})"
52
+
53
+ # Gradio arayüzü
54
+ interface = gr.Interface(
55
+ fn=analyze_sentiment,
56
+ inputs=gr.Textbox(label="Enter Text"),
57
+ outputs=gr.Textbox(label="Sentiment Analysis Result")
58
+ )
59
+
60
+ # Arayüzü başlatın
61
+ interface.launch(share=True)