Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -22,10 +22,18 @@ import torch
|
|
| 22 |
import matplotlib.pyplot as plt
|
| 23 |
from torchvision.transforms import ToTensor, ToPILImage
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
client = OpenAI()
|
| 27 |
|
| 28 |
-
pipe = pipeline("zero-shot-image-classification", model="patrickjohncyh/fashion-clip")
|
| 29 |
|
| 30 |
color_file_path = 'color_config.json'
|
| 31 |
attributes_file_path = 'attributes_config.json'
|
|
|
|
| 22 |
import matplotlib.pyplot as plt
|
| 23 |
from torchvision.transforms import ToTensor, ToPILImage
|
| 24 |
|
| 25 |
+
if torch.cuda.is_available():
|
| 26 |
+
device = 0
|
| 27 |
+
print("CUDA is available. Using GPU.")
|
| 28 |
+
else:
|
| 29 |
+
device = -1
|
| 30 |
+
print("CUDA is not available. Using CPU.")
|
| 31 |
+
|
| 32 |
+
|
| 33 |
|
| 34 |
client = OpenAI()
|
| 35 |
|
| 36 |
+
pipe = pipeline("zero-shot-image-classification", model="patrickjohncyh/fashion-clip", device=device)
|
| 37 |
|
| 38 |
color_file_path = 'color_config.json'
|
| 39 |
attributes_file_path = 'attributes_config.json'
|