RP-Azul commited on
Commit
1128830
·
verified ·
1 Parent(s): c16c3d0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -2,8 +2,11 @@ import gradio as gr
2
  from PIL import Image
3
  # Use a pipeline as a high-level helper
4
  from transformers import pipeline
 
5
 
6
- pipe = pipeline("zero-shot-image-classification", model="openai/clip-vit-large-patch14")
 
 
7
  def classify_image(image):
8
  result = pipe(image, ["cat", "dog", "car", "person", "building"])
9
  return result
 
2
  from PIL import Image
3
  # Use a pipeline as a high-level helper
4
  from transformers import pipeline
5
+ import torch
6
 
7
+ device = "cuda" if torch.cuda.is_available() else "cpu"
8
+
9
+ pipe = pipeline("zero-shot-image-classification", model="openai/clip-vit-large-patch14",device=0 if device == "cuda" else -1)
10
  def classify_image(image):
11
  result = pipe(image, ["cat", "dog", "car", "person", "building"])
12
  return result