samariddin commited on
Commit
832b1d7
1 Parent(s): 0f07279
.idea/.gitignore ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ # Default ignored files
2
+ /shelf/
3
+ /workspace.xml
.idea/inspectionProfiles/Project_Default.xml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <component name="InspectionProjectProfileManager">
2
+ <profile version="1.0">
3
+ <option name="myName" value="Project Default" />
4
+ <inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
5
+ <option name="ignoredPackages">
6
+ <value>
7
+ <list size="1">
8
+ <item index="0" class="java.lang.String" itemvalue="gradio" />
9
+ </list>
10
+ </value>
11
+ </option>
12
+ </inspection_tool>
13
+ </profile>
14
+ </component>
.idea/inspectionProfiles/profiles_settings.xml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ <component name="InspectionProjectProfileManager">
2
+ <settings>
3
+ <option name="USE_PROJECT_PROFILE" value="false" />
4
+ <version value="1.0" />
5
+ </settings>
6
+ </component>
.idea/misc.xml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8 (uz_news_classifer)" project-jdk-type="Python SDK" />
4
+ </project>
.idea/modules.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/uz_news_classifer.iml" filepath="$PROJECT_DIR$/.idea/uz_news_classifer.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
.idea/uz_news_classifer.iml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="PYTHON_MODULE" version="4">
3
+ <component name="NewModuleRootManager">
4
+ <content url="file://$MODULE_DIR$">
5
+ <excludeFolder url="file://$MODULE_DIR$/venv" />
6
+ </content>
7
+ <orderEntry type="jdk" jdkName="Python 3.8 (uz_news_classifer)" jdkType="Python SDK" />
8
+ <orderEntry type="sourceFolder" forTests="false" />
9
+ </component>
10
+ </module>
.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="" vcs="Git" />
5
+ </component>
6
+ </project>
app.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ from transformers import AutoModelForSequenceClassification, AutoTokenizer, pipeline
4
+
5
+ MODEL_URL = "https://huggingface.co/serdarakyol/interpress-turkish-news-classification"
6
+ WEBSITE_URL = "https://www.kodiks.com/ai_solutions.html"
7
+
8
+ tokenizer = AutoTokenizer.from_pretrained("coppercitylabs/uzbek-news-category-classifier")
9
+ model = AutoModelForSequenceClassification.from_pretrained("coppercitylabs/uzbek-news-category-classifier")
10
+
11
+ def prediction(news):
12
+ # create pipeline
13
+ clasifer = pipeline("sentiment-analysis", tokenizer=tokenizer, model=model, return_all_scores=True)
14
+
15
+ preds = clasifer(news)
16
+
17
+ preds_dict={}
18
+ for pred in preds[0]:
19
+ preds_dict[pred['label']] = pred['score']
20
+
21
+ return preds_dict
22
+
23
+
24
+ gradio_ui = gr.Interface(
25
+ fn=prediction,
26
+ title="Turkish News Classification",
27
+ description=f"Enter Turkish news article to see the category of the news.\n For this classification, the {MODEL_URL} model was used.",
28
+ examples=[
29
+ ['Son dakika haberi... Sağlık Bakanlığı corona virüsü (koronavirüs) için son gelişmeleri ve Türkiye Günlük Korona Tablosu\'nu açıkladı. Türkiye\'de son 24 saatte 355 bin 947 Kovid-19 testi yapıldı, 26 bin 896 kişinin testi pozitif çıktı, 210 kişi yaşamını yitirdi. Tabloda vaka ve vefat sayılarına dikkat çeken Bakan Koca, "Bu ölümlerin bir kısmı birden çok sebebin bir araya gelmesine bağlı ve önlenebilir. Örneğin, Covid-19’a kronik hastalıkların eşlik etmesi riski artıran bir faktör. Tam doz aşı bu riski azaltıyor." çağrısında bulundu. Öte yandan ikinci doz aşılama oranı %75\'e çıkan Tunceli, mavi kategoriye yükseldi.'],
30
+ ["Galatasaray'dan sezon başında ayrılan ve Rayo Vallecano'nun yolunu tutan Radamel Falcao, İspanya'da şov yapmaya devam ediyor. Kolombiyalı yıldızın, Barcelona karşısında attığı gol maça damga vurdu."],
31
+ ["Instagram, 3 yıl önce kullanıcıların beğenisine sunduğu IGTV özelliğini kaldırıyor. IGTV’nin yerine gelecek yeni özelliğin ise platformun Reels'tan elde ettiği başarıyı pekiştirip içerik üreticileri için kullanışlı bir zemin oluşturması bekleniyor."],
32
+ ["Kamu bankaları Halkbank, Vakıfbank ve Ziraat Bankası ortak bir açıklama yayınlayarak kredi faiz oranlarında indirim yapıldığını açıkladı. Söz konusu indirimler ticari ve konut kredileri kapsıyor. Tüketici kredisi kapsam dışında bırakıldı."]
33
+ ],
34
+ inputs=gr.inputs.Textbox(lines=10, label="Paste some news here"),
35
+ outputs=gr.outputs.Label(num_top_classes=5, type="auto", label="News categories probabilities"),
36
+ theme="huggingface",
37
+ article="<p style='text-align: center'>for our other AI works: <a href='https://www.kodiks.com/ai_solutions.html' target='_blank'>https://www.kodiks.com/ai_solutions.html</a> | <a href='https://twitter.com/KodiksBilisim' target='_blank'>Contact us</a></p>",
38
+ )
39
+
40
+ gradio_ui.launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio==2.2.6
2
+ transformers
3
+ torch