pavankumarhm commited on
Commit
2f879b8
·
1 Parent(s): 4cae739

Upload folder using huggingface_hub

Browse files
.DS_Store ADDED
Binary file (8.2 kB). View file
 
.env ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+
2
+
3
+ PARAM1=26f3c9103emsh4bd4451b35fd851p1b847bjsn99dfadd7f4ce
4
+
5
+ PARAM2=twinword-sentiment-analysis.p.rapidapi.com
.gitattributes CHANGED
@@ -32,3 +32,7 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
32
  *.zip filter=lfs diff=lfs merge=lfs -text
33
  *.zst filter=lfs diff=lfs merge=lfs -text
34
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
32
  *.zip filter=lfs diff=lfs merge=lfs -text
33
  *.zst filter=lfs diff=lfs merge=lfs -text
34
  *tfevents* filter=lfs diff=lfs merge=lfs -text
35
+ word2vec_model.tf filter=lfs diff=lfs merge=lfs -text
36
+ ~/tensorflow_datasets/imdb_reviews/plain_text/1.0.0/imdb_reviews-test.tfrecord-00000-of-00001 filter=lfs diff=lfs merge=lfs -text
37
+ ~/tensorflow_datasets/imdb_reviews/plain_text/1.0.0/imdb_reviews-train.tfrecord-00000-of-00001 filter=lfs diff=lfs merge=lfs -text
38
+ ~/tensorflow_datasets/imdb_reviews/plain_text/1.0.0/imdb_reviews-unsupervised.tfrecord-00000-of-00001 filter=lfs diff=lfs merge=lfs -text
.github/workflows/update_space.yml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Run Python script
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - n
7
+
8
+ jobs:
9
+ build:
10
+ runs-on: ubuntu-latest
11
+
12
+ steps:
13
+ - name: Checkout
14
+ uses: actions/checkout@v2
15
+
16
+ - name: Set up Python
17
+ uses: actions/setup-python@v2
18
+ with:
19
+ python-version: '3.9'
20
+
21
+ - name: Install Gradio
22
+ run: python -m pip install gradio
23
+
24
+ - name: Log in to Hugging Face
25
+ run: python -c 'import huggingface_hub; huggingface_hub.login(token="${{ secrets.hf_token }}")'
26
+
27
+ - name: Deploy to Spaces
28
+ run: gradio deploy
README.md CHANGED
@@ -1,12 +1,7 @@
1
  ---
2
- title: Sentiment Analyzer
3
- emoji: 📈
4
- colorFrom: purple
5
- colorTo: blue
6
  sdk: gradio
7
  sdk_version: 3.33.1
8
- app_file: app.py
9
- pinned: false
10
  ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: Sentiment_Analyzer
3
+ app_file: Sentiment_Analyzer_app.py
 
 
4
  sdk: gradio
5
  sdk_version: 3.33.1
 
 
6
  ---
7
+ # Sentiment_Analyzer
 
Sample_Sentiment_Analyzer.py ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import requests
3
+ from textblob import TextBlob
4
+ import matplotlib.pyplot as plt
5
+ import os
6
+
7
+ # Replace with your API endpoint and parameters
8
+ from dotenv import load_dotenv
9
+
10
+
11
+ # Load environment variables from .env file
12
+ load_dotenv()
13
+
14
+ headers = {
15
+ "X-RapidAPI-Key": os.getenv("PARAM1"),
16
+ "X-RapidAPI-Host": os.getenv("PARAM2")
17
+ }
18
+
19
+
20
+
21
+ # Make the API request
22
+ url = "https://twinword-sentiment-analysis.p.rapidapi.com/analyze/"
23
+
24
+ querystring = {"text":input("Enter the text to analyze:")}
25
+
26
+
27
+ # Make the API request
28
+ response = requests.get(url, headers=headers, params=querystring)
29
+
30
+ # Check if the request was successful
31
+ if response.status_code == 200:
32
+ # Extract the text data from the API response
33
+ text_data = response.text
34
+
35
+ # Analyze sentiment using TextBlob
36
+ blob = TextBlob(text_data)
37
+ sentiment = blob.sentiment.polarity
38
+
39
+ # Determine sentiment category
40
+ if sentiment > 0:
41
+ sentiment_category = "positive"
42
+ elif sentiment < 0:
43
+ sentiment_category = "negative"
44
+ else:
45
+ sentiment_category = "neutral"
46
+
47
+ print(f"Sentiment: {sentiment_category} ({sentiment})")
48
+
49
+ else:
50
+ print(f"Error: API request failed with status code {response.status_code}")
Sentiment_Analysis_Gradio.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
Sentiment_Analyzer_app.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+ classifier = pipeline("sentiment-analysis")
3
+
4
+ def func(utterance):
5
+ return classifier(utterance)
6
+ import gradio as gr
7
+ descriptions = "Enter a text and get the sentiment prediction."
8
+ app = gr.Interface(fn=func, inputs="text", outputs="text", title="Sentiment Analayzer", description=descriptions)
9
+ app.launch(share=True)
flagged/log.csv ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ Input Text,Sentiment,flag,username,timestamp
2
+ Hello. How are you crying?,Negative,,,2023-06-05 15:02:46.499733
3
+ Hello. How are you crying?,Negative,,,2023-06-05 15:02:49.320540
4
+ ,,,,2023-06-05 17:48:47.143025
my_model.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a4d0a4c3f2887eb0b4e59e7313f62735f6acc686145802d0656a80460bf756da
3
+ size 114832
my_model.tf/.DS_Store ADDED
Binary file (6.15 kB). View file
 
my_model.tf/keras_metadata.pb ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f3d423e97e2f1267eba2b1e43d9a13312a8f64dc7270c578a5cab0e500f61603
3
+ size 11475
my_model.tf/saved_model.pb ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9f7c6cdf494ef5a22f16fb97a9791ebb56b84a5f44484840c82995f39938957b
3
+ size 1576479
my_model.tf/variables/variables.data-00000-of-00001 ADDED
Binary file (86.8 kB). View file
 
my_model.tf/variables/variables.index ADDED
Binary file (1.63 kB). View file
 
word2vec.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:973cea0662f6cf95a55fbc9a9a9fab5f49f00d0507f1ea4437657adf0edf2ff5
3
+ size 3899332
word2vec_model.tf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e565febc46550f9ee20ff5a2ca0e408d8d39d53a784b738c03d878de5ee77bb4
3
+ size 3899334
~/tensorflow_datasets/imdb_reviews/.config/metadata.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"default_config_name": "plain_text"}
~/tensorflow_datasets/imdb_reviews/plain_text/1.0.0/dataset_info.json ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "citation": "@InProceedings{maas-EtAl:2011:ACL-HLT2011,\n author = {Maas, Andrew L. and Daly, Raymond E. and Pham, Peter T. and Huang, Dan and Ng, Andrew Y. and Potts, Christopher},\n title = {Learning Word Vectors for Sentiment Analysis},\n booktitle = {Proceedings of the 49th Annual Meeting of the Association for Computational Linguistics: Human Language Technologies},\n month = {June},\n year = {2011},\n address = {Portland, Oregon, USA},\n publisher = {Association for Computational Linguistics},\n pages = {142--150},\n url = {http://www.aclweb.org/anthology/P11-1015}\n}",
3
+ "configDescription": "Plain text",
4
+ "configName": "plain_text",
5
+ "description": "Large Movie Review Dataset.\nThis is a dataset for binary sentiment classification containing substantially more data than previous benchmark datasets. We provide a set of 25,000 highly polar movie reviews for training, and 25,000 for testing. There is additional unlabeled data for use as well.",
6
+ "downloadSize": "84125825",
7
+ "fileFormat": "tfrecord",
8
+ "location": {
9
+ "urls": [
10
+ "http://ai.stanford.edu/~amaas/data/sentiment/"
11
+ ]
12
+ },
13
+ "moduleName": "tensorflow_datasets.text.imdb",
14
+ "name": "imdb_reviews",
15
+ "releaseNotes": {
16
+ "1.0.0": "New split API (https://tensorflow.org/datasets/splits)"
17
+ },
18
+ "schema": {
19
+ "feature": [
20
+ {
21
+ "name": "label",
22
+ "type": "INT"
23
+ },
24
+ {
25
+ "name": "text",
26
+ "type": "BYTES"
27
+ }
28
+ ]
29
+ },
30
+ "sizeInBytes": "84125825",
31
+ "splits": [
32
+ {
33
+ "filepathTemplate": "{DATASET}-{SPLIT}.{FILEFORMAT}-{SHARD_X_OF_Y}",
34
+ "name": "train",
35
+ "numBytes": "34057750",
36
+ "shardLengths": [
37
+ "25000"
38
+ ],
39
+ "statistics": {
40
+ "features": [
41
+ {
42
+ "name": "label",
43
+ "numStats": {
44
+ "commonStats": {
45
+ "numNonMissing": "25000"
46
+ },
47
+ "max": 1.0
48
+ }
49
+ },
50
+ {
51
+ "bytesStats": {
52
+ "commonStats": {
53
+ "numNonMissing": "25000"
54
+ }
55
+ },
56
+ "name": "text",
57
+ "type": "BYTES"
58
+ }
59
+ ],
60
+ "numExamples": "25000"
61
+ }
62
+ },
63
+ {
64
+ "filepathTemplate": "{DATASET}-{SPLIT}.{FILEFORMAT}-{SHARD_X_OF_Y}",
65
+ "name": "test",
66
+ "numBytes": "33275595",
67
+ "shardLengths": [
68
+ "25000"
69
+ ],
70
+ "statistics": {
71
+ "features": [
72
+ {
73
+ "name": "label",
74
+ "numStats": {
75
+ "commonStats": {
76
+ "numNonMissing": "25000"
77
+ },
78
+ "max": 1.0
79
+ }
80
+ },
81
+ {
82
+ "bytesStats": {
83
+ "commonStats": {
84
+ "numNonMissing": "25000"
85
+ }
86
+ },
87
+ "name": "text",
88
+ "type": "BYTES"
89
+ }
90
+ ],
91
+ "numExamples": "25000"
92
+ }
93
+ },
94
+ {
95
+ "filepathTemplate": "{DATASET}-{SPLIT}.{FILEFORMAT}-{SHARD_X_OF_Y}",
96
+ "name": "unsupervised",
97
+ "numBytes": "68806612",
98
+ "shardLengths": [
99
+ "50000"
100
+ ],
101
+ "statistics": {
102
+ "features": [
103
+ {
104
+ "name": "label",
105
+ "numStats": {
106
+ "commonStats": {
107
+ "numNonMissing": "50000"
108
+ },
109
+ "max": -1.0,
110
+ "min": -1.0
111
+ }
112
+ },
113
+ {
114
+ "bytesStats": {
115
+ "commonStats": {
116
+ "numNonMissing": "50000"
117
+ }
118
+ },
119
+ "name": "text",
120
+ "type": "BYTES"
121
+ }
122
+ ],
123
+ "numExamples": "50000"
124
+ }
125
+ }
126
+ ],
127
+ "supervisedKeys": {
128
+ "tuple": {
129
+ "items": [
130
+ {
131
+ "featureKey": "text"
132
+ },
133
+ {
134
+ "featureKey": "label"
135
+ }
136
+ ]
137
+ }
138
+ },
139
+ "version": "1.0.0"
140
+ }
~/tensorflow_datasets/imdb_reviews/plain_text/1.0.0/features.json ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "pythonClassName": "tensorflow_datasets.core.features.features_dict.FeaturesDict",
3
+ "featuresDict": {
4
+ "features": {
5
+ "text": {
6
+ "pythonClassName": "tensorflow_datasets.core.features.text_feature.Text",
7
+ "text": {}
8
+ },
9
+ "label": {
10
+ "pythonClassName": "tensorflow_datasets.core.features.class_label_feature.ClassLabel",
11
+ "classLabel": {
12
+ "numClasses": "2"
13
+ }
14
+ }
15
+ }
16
+ }
17
+ }
~/tensorflow_datasets/imdb_reviews/plain_text/1.0.0/imdb_reviews-test.tfrecord-00000-of-00001 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5102d5b92e30ba2bc678da78f31e5b6320d71ad7bf072b1ae06cf6033db7d52f
3
+ size 33675595
~/tensorflow_datasets/imdb_reviews/plain_text/1.0.0/imdb_reviews-train.tfrecord-00000-of-00001 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:054a66c814775566ad3e00660e37def57ff1c10e9e0a822493150d1139c87acd
3
+ size 34457750
~/tensorflow_datasets/imdb_reviews/plain_text/1.0.0/imdb_reviews-unsupervised.tfrecord-00000-of-00001 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1341a1eb64c70cf9a96734ba505038b28e4903f89220a72f0038a1e895697885
3
+ size 69606612
~/tensorflow_datasets/imdb_reviews/plain_text/1.0.0/label.labels.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ neg
2
+ pos