whitphx HF Staff commited on
Commit
f446279
·
1 Parent(s): 09ebece
Files changed (1) hide show
  1. index.html +6 -3
index.html CHANGED
@@ -19,9 +19,12 @@ pipeline = transformers.pipeline
19
  pipe = await pipeline('zero-shot-image-classification')
20
 
21
  async def classify(image, classes):
22
- data = await pipe(as_url(image), [c for c in classes.split(",") if c])
23
- result = {item['label']: round(item['score'], 2) for item in data}
24
- return result
 
 
 
25
 
26
  demo = gr.Interface(
27
  classify,
 
19
  pipe = await pipeline('zero-shot-image-classification')
20
 
21
  async def classify(image, classes):
22
+ classes = [c for c in classes.split(",") if c]
23
+ if not classes:
24
+ return {}
25
+ data = await pipe(as_url(image), classes)
26
+ result = {item['label']: round(item['score'], 2) for item in data}
27
+ return result
28
 
29
  demo = gr.Interface(
30
  classify,