Ubuntu commited on
Commit
f4ecb39
1 Parent(s): 497be6c

Convert model to OpenVINO

Browse files
Files changed (2) hide show
  1. app.py +8 -2
  2. requirements.txt +1 -0
app.py CHANGED
@@ -1,9 +1,15 @@
1
  import gradio as gr
2
- from transformers import pipeline
 
 
3
 
4
  model_id = "juliensimon/xlm-v-base-language-id"
 
 
 
 
5
 
6
- p = pipeline("text-classification", model=model_id)
7
 
8
 
9
  def process(text, top_k=5):
 
1
  import gradio as gr
2
+ from optimum.intel.openvino import OVModelForSequenceClassification
3
+ from transformers import (AutoModelForSequenceClassification, AutoTokenizer,
4
+ pipeline)
5
 
6
  model_id = "juliensimon/xlm-v-base-language-id"
7
+ ov_model = OVModelForSequenceClassification.from_pretrained(
8
+ model_id, from_transformers=True
9
+ )
10
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
11
 
12
+ p = pipeline("text-classification", model=ov_model, tokenizer=tokenizer)
13
 
14
 
15
  def process(text, top_k=5):
requirements.txt CHANGED
@@ -1,2 +1,3 @@
1
  torch
2
  transformers
 
 
1
  torch
2
  transformers
3
+ optimum[openvino,nncf]