offry commited on
Commit
7c5a026
·
verified ·
1 Parent(s): 713abf1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -1
app.py CHANGED
@@ -34,7 +34,22 @@ def create_retrieval_figure(res):
34
  image = cv2.imdecode(np.frombuffer(imgfile, np.uint8), 1)
35
  # image_resized = cv2.resize(image, (224, 224), interpolation=cv2.INTER_LINEAR)
36
  except Exception:
37
- image = cv2.imdecode(np.array((224, 224, 3), np.uint8), 1)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  ax = fig.add_subplot(rows, cols, i + 1)
39
  plt.axis('off')
40
  plt.imshow(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))
 
34
  image = cv2.imdecode(np.frombuffer(imgfile, np.uint8), 1)
35
  # image_resized = cv2.resize(image, (224, 224), interpolation=cv2.INTER_LINEAR)
36
  except Exception:
37
+ image = np.ones((224, 224, 3), dtype=np.uint8) * 255
38
+ text = "file not found"
39
+ font = cv2.FONT_HERSHEY_SIMPLEX
40
+ font_scale = 0.7
41
+ font_thickness = 1
42
+ text_color = (0, 0, 0) # Black color
43
+
44
+ # Get the size of the text
45
+ (text_width, text_height), _ = cv2.getTextSize(text, font, font_scale, font_thickness)
46
+
47
+ # Calculate the center position of the text
48
+ text_x = (image.shape[1] - text_width) // 2
49
+ text_y = (image.shape[0] + text_height) // 2
50
+
51
+ # Put the text on the image
52
+ cv2.putText(image, text, (text_x, text_y), font, font_scale, text_color, font_thickness)
53
  ax = fig.add_subplot(rows, cols, i + 1)
54
  plt.axis('off')
55
  plt.imshow(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))