arad1367 commited on
Commit
cbd54ec
·
verified ·
1 Parent(s): 64ea3ca

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -23,7 +23,7 @@ def preprocess_image(image_path, max_size=(800, 800)):
23
  image.thumbnail(max_size, Image.LANCZOS)
24
 
25
  # Convert image to numpy array
26
- image_np = np.array(image)
27
 
28
  # Ensure the image is in the format [height, width, channels]
29
  if image_np.ndim == 2: # Grayscale image
@@ -65,7 +65,7 @@ def run_florence_model(image_np, image_size, task_prompt, text_input=None):
65
  # Function to plot image with bounding boxes
66
  def plot_image_with_bboxes(image_np, bboxes, labels=None):
67
  fig, ax = plt.subplots(1)
68
- ax.imshow(image_np)
69
  colors = ['red', 'blue', 'green', 'yellow', 'purple', 'cyan']
70
  for i, bbox in enumerate(bboxes):
71
  color = colors[i % len(colors)]
@@ -159,4 +159,4 @@ with gr.Blocks(theme='NoCrypt/miku') as demo:
159
  """
160
  gr.HTML(footer)
161
 
162
- demo.launch()
 
23
  image.thumbnail(max_size, Image.LANCZOS)
24
 
25
  # Convert image to numpy array
26
+ image_np = np.array(image, dtype=np.float32) # Ensure the array is float32
27
 
28
  # Ensure the image is in the format [height, width, channels]
29
  if image_np.ndim == 2: # Grayscale image
 
65
  # Function to plot image with bounding boxes
66
  def plot_image_with_bboxes(image_np, bboxes, labels=None):
67
  fig, ax = plt.subplots(1)
68
+ ax.imshow(image_np / 255.0) # Normalize the image for plotting
69
  colors = ['red', 'blue', 'green', 'yellow', 'purple', 'cyan']
70
  for i, bbox in enumerate(bboxes):
71
  color = colors[i % len(colors)]
 
159
  """
160
  gr.HTML(footer)
161
 
162
+ demo.launch()