Romanchik333 commited on
Commit
82d4600
·
verified ·
1 Parent(s): 48efab6
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -4,7 +4,7 @@ from transformers import pipeline
4
  #sentencepiece no installed??
5
 
6
  translator = pipeline("translation_en_to_ru", model="Helsinki-NLP/opus-mt-en-ru")
7
- image_classifier = pipeline("image-classification", model="microsoft/resnet-50", use_fast=False)
8
 
9
  def translate_to_russian(text):
10
  try:
@@ -17,8 +17,12 @@ def translate_to_russian(text):
17
  def classify_image(image):
18
  results = image_classifier(image)
19
  output = {}
 
20
  for result in results:
21
  output[translate_to_russian(result['label'])] = result['score']
 
 
 
22
  return output
23
 
24
  with gr.Blocks() as demo:
 
4
  #sentencepiece no installed??
5
 
6
  translator = pipeline("translation_en_to_ru", model="Helsinki-NLP/opus-mt-en-ru")
7
+ image_classifier = pipeline("image-classification", model="microsoft/resnet-50")
8
 
9
  def translate_to_russian(text):
10
  try:
 
17
  def classify_image(image):
18
  results = image_classifier(image)
19
  output = {}
20
+ count = 0
21
  for result in results:
22
  output[translate_to_russian(result['label'])] = result['score']
23
+ count += 1
24
+ if (count > 5):
25
+ break
26
  return output
27
 
28
  with gr.Blocks() as demo: