lgblkb commited on
Commit
14f73ef
1 Parent(s): 6d9ae67

Download model during runtime

Browse files
Files changed (3) hide show
  1. README.md +2 -2
  2. app.py +15 -0
  3. requirements.txt +2 -1
README.md CHANGED
@@ -10,8 +10,8 @@ pinned: false
10
  license: cc-by-4.0
11
  python_version: 3.12
12
  short_description: KazSandra project @ ISSAI
13
- preload_from_hub:
14
- - "issai/rembert-sentiment-analysis-polarity-classification-kazakh"
15
  ---
16
 
17
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
10
  license: cc-by-4.0
11
  python_version: 3.12
12
  short_description: KazSandra project @ ISSAI
13
+ #preload_from_hub:
14
+ #- "issai/rembert-sentiment-analysis-polarity-classification-kazakh"
15
  ---
16
 
17
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py CHANGED
@@ -12,3 +12,18 @@ login(os.getenv('HF_TOKEN'))
12
  hub_folder = Path('~/.cache/huggingface/hub')
13
  for path in hub_folder.walk():
14
  st.write(path)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  hub_folder = Path('~/.cache/huggingface/hub')
13
  for path in hub_folder.walk():
14
  st.write(path)
15
+
16
+ from transformers import AutoModelForSequenceClassification
17
+ from transformers import AutoTokenizer
18
+ from transformers import TextClassificationPipeline
19
+
20
+ model = AutoModelForSequenceClassification.from_pretrained(
21
+ "issai/rembert-sentiment-analysis-polarity-classification-kazakh")
22
+ tokenizer = AutoTokenizer.from_pretrained("issai/rembert-sentiment-analysis-polarity-classification-kazakh")
23
+
24
+ pipe = TextClassificationPipeline(model=model, tokenizer=tokenizer)
25
+
26
+ reviews = ["Бұл бейнефильм маған түк ұнамады.", "Осы кітап қызық сияқты."]
27
+
28
+ for review in reviews:
29
+ st.write(pipe(review))
requirements.txt CHANGED
@@ -1 +1,2 @@
1
- streamlit~=1.37.0
 
 
1
+ streamlit~=1.37.0
2
+ huggingface-hub~=0.24.5