MarioPrzBasto commited on
Commit
c2df641
·
verified ·
1 Parent(s): f1ea500

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +3 -3
main.py CHANGED
@@ -67,7 +67,6 @@ def mobilenet_similarity(img1, img2):
67
 
68
  sim = cosine_similarity(feat1, feat2)[0][0] # Valor entre -1 e 1
69
  sim_score = (sim + 1) * 50 # Escalar para 0-100
70
- print(f"MobileNet similarity score is {sim_score}")
71
  return float(sim_score)
72
  except Exception as e:
73
  print("Erro ao calcular similaridade com MobileNet")
@@ -77,6 +76,7 @@ def load_image(source, ffmpeg_path='ffmpeg', frame_time=1):
77
  Image.MAX_IMAGE_PIXELS = None
78
 
79
  def extract_frame_from_video(video_path_or_url, time_sec):
 
80
  with tempfile.NamedTemporaryFile(suffix='.jpg', delete=False) as temp_frame:
81
  frame_path = temp_frame.name
82
 
@@ -96,6 +96,8 @@ def load_image(source, ffmpeg_path='ffmpeg', frame_time=1):
96
 
97
  frame = cv2.imread(frame_path, cv2.IMREAD_GRAYSCALE)
98
  os.remove(frame_path)
 
 
99
  return frame
100
 
101
  if source.startswith('http'):
@@ -142,9 +144,7 @@ async def save(image_data: RequestModel):
142
 
143
  if img1 is not None and img2 is not None:
144
  similarity_orb = orb_sim(img1, img2)
145
- print(f"Similaridade ORB entre {image_data.originSource} e {image_data.source}: {similarity_orb}")
146
  similarity_mobilenet = mobilenet_similarity(img1, img2)
147
- print(f"Similaridade Mobilenet entre {image_data.originSource} e {image_data.source}: {similarity_mobilenet}")
148
 
149
  data_to_save = image_data.dict()
150
  if similarity_orb is not None:
 
67
 
68
  sim = cosine_similarity(feat1, feat2)[0][0] # Valor entre -1 e 1
69
  sim_score = (sim + 1) * 50 # Escalar para 0-100
 
70
  return float(sim_score)
71
  except Exception as e:
72
  print("Erro ao calcular similaridade com MobileNet")
 
76
  Image.MAX_IMAGE_PIXELS = None
77
 
78
  def extract_frame_from_video(video_path_or_url, time_sec):
79
+ print(f"A extrair video com url {video_path_or_url}")
80
  with tempfile.NamedTemporaryFile(suffix='.jpg', delete=False) as temp_frame:
81
  frame_path = temp_frame.name
82
 
 
96
 
97
  frame = cv2.imread(frame_path, cv2.IMREAD_GRAYSCALE)
98
  os.remove(frame_path)
99
+
100
+ print(f"Video com url {video_path_or_url} extraido")
101
  return frame
102
 
103
  if source.startswith('http'):
 
144
 
145
  if img1 is not None and img2 is not None:
146
  similarity_orb = orb_sim(img1, img2)
 
147
  similarity_mobilenet = mobilenet_similarity(img1, img2)
 
148
 
149
  data_to_save = image_data.dict()
150
  if similarity_orb is not None: