mattb512 commited on
Commit
94c65ad
1 Parent(s): e4a77bc

check for gpu

Browse files
Files changed (1) hide show
  1. app.py +4 -0
app.py CHANGED
@@ -4,6 +4,7 @@ import numpy as np
4
  from torch import nn
5
  import gradio as gr
6
  import os
 
7
 
8
  feature_extractor = SegformerFeatureExtractor.from_pretrained("nvidia/segformer-b5-finetuned-cityscapes-1024-1024")
9
  model = SegformerForSemanticSegmentation.from_pretrained("nvidia/segformer-b5-finetuned-cityscapes-1024-1024")
@@ -50,6 +51,9 @@ def annotation(image:ImageDraw, color_seg:np.array):
50
 
51
  def call(image): #nparray
52
 
 
 
 
53
  resized = Image.fromarray(image).resize((1024,1024))
54
  resized_image = np.array(resized)
55
  print(f"{np.array(resized_image).shape=}") # 1024, 1024, 3
 
4
  from torch import nn
5
  import gradio as gr
6
  import os
7
+ import torch
8
 
9
  feature_extractor = SegformerFeatureExtractor.from_pretrained("nvidia/segformer-b5-finetuned-cityscapes-1024-1024")
10
  model = SegformerForSemanticSegmentation.from_pretrained("nvidia/segformer-b5-finetuned-cityscapes-1024-1024")
 
51
 
52
  def call(image): #nparray
53
 
54
+ print(f"Is CUDA available: {torch.cuda.is_available()}")
55
+ print(f"CUDA device: {torch.cuda.get_device_name(torch.cuda.current_device())}")
56
+
57
  resized = Image.fromarray(image).resize((1024,1024))
58
  resized_image = np.array(resized)
59
  print(f"{np.array(resized_image).shape=}") # 1024, 1024, 3