Galaxydude2 commited on
Commit
5f368d9
路
verified 路
1 Parent(s): 4eb5dc8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -15
app.py CHANGED
@@ -1,15 +1,10 @@
1
-
2
- import sys
3
- if 'google.colab' in sys.modules:
4
- !pip install deepface nudenet opencv-python
5
-
6
  from PIL import Image, ImageDraw, ImageFont
7
  import numpy as np
8
  import gradio as gr
9
  import os
10
- import cv2
11
- from deepface import DeepFace
12
- from nudenet import NudeDetector
13
  import io
14
  import tempfile
15
 
@@ -202,7 +197,7 @@ def estimate_age(crop_img):
202
  return "Alter nicht bestimmbar"
203
 
204
  # Initialize NudeDetector
205
- detector = NudeDetector()
206
 
207
  def analyze_image_with_gradio(input_image_path):
208
  print(f"[INFO] analyze_image_with_gradio called with path: {input_image_path}")
@@ -366,7 +361,7 @@ def analyze_image_with_gradio(input_image_path):
366
  bbox_label_global = FONT_LABEL_SIMPLE.getbbox(label_global_simple)
367
  text_width_global = bbox_label_global[2] - bbox_label_global[0]
368
  text_height_global = bbox_label_global[3] - bbox_label_global[1]
369
- draw_annotated.rectangle([(x1, y1 - text_height_global - 2), (x1 + text_width_global, y1)], fill=(255, 255, 0))
370
  draw_annotated.text((x1, y1 - text_height_global - 2), label_global_simple, font=FONT_LABEL_SIMPLE, fill=BACKGROUND_COLOR)
371
 
372
  crop = original_img.crop((x1, y1, x2, y2))
@@ -403,10 +398,10 @@ def analyze_image_with_gradio(input_image_path):
403
  crop = original_img.crop(b_data['bbox'])
404
  desc = describe_breast_precise(crop) + f" 路 Alter: {b_data['age_str']}"
405
  current_image_crops_with_details.append((f"Global Brust (einzeln)", resize_crop(crop, TARGET_MAX_DIMENSION), desc))
406
- else:
407
- merged_breast_crop = original_img.crop((x1_final, y1_final, x2_final, y2_final))
408
- desc = describe_breast_precise(merged_breast_crop) + f" 路 Alter: {global_breasts_for_merging[0]['age_str']}"
409
- current_image_crops_with_details.append((f"Global Br眉ste (beide)", resize_crop(merged_breast_crop, TARGET_MAX_DIMENSION), desc))
410
  else:
411
  b_data = global_breasts_for_merging[0]
412
  crop = original_img.crop(b_data['bbox'])
@@ -561,4 +556,4 @@ interface = gr.Interface(
561
  )
562
 
563
  if __name__ == "__main__":
564
- interface.launch(debug=False, share=True)
 
 
 
 
 
 
1
  from PIL import Image, ImageDraw, ImageFont
2
  import numpy as np
3
  import gradio as gr
4
  import os
5
+ import cv2 # Explicitly adding cv2 import
6
+ from deepface import DeepFace # Explicitly adding DeepFace import
7
+ from nudenet import NudeDetector # Explicitly adding NudeDetector import
8
  import io
9
  import tempfile
10
 
 
197
  return "Alter nicht bestimmbar"
198
 
199
  # Initialize NudeDetector
200
+ detector = NudeDetector() # NudeDetector instantiation
201
 
202
  def analyze_image_with_gradio(input_image_path):
203
  print(f"[INFO] analyze_image_with_gradio called with path: {input_image_path}")
 
361
  bbox_label_global = FONT_LABEL_SIMPLE.getbbox(label_global_simple)
362
  text_width_global = bbox_label_global[2] - bbox_label_global[0]
363
  text_height_global = bbox_label_global[3] - bbox_label_global[1]
364
+ draw_annotated.rectangle([(x1, y1 - text_height_global - 2), (x1 + text_width_global, y1)], fill=BACKGROUND_COLOR)
365
  draw_annotated.text((x1, y1 - text_height_global - 2), label_global_simple, font=FONT_LABEL_SIMPLE, fill=BACKGROUND_COLOR)
366
 
367
  crop = original_img.crop((x1, y1, x2, y2))
 
398
  crop = original_img.crop(b_data['bbox'])
399
  desc = describe_breast_precise(crop) + f" 路 Alter: {b_data['age_str']}"
400
  current_image_crops_with_details.append((f"Global Brust (einzeln)", resize_crop(crop, TARGET_MAX_DIMENSION), desc))
401
+ else:
402
+ merged_breast_crop = original_img.crop((x1_final, y1_final, x2_final, y2_final))
403
+ desc = describe_breast_precise(merged_breast_crop) + f" 路 Alter: {global_breasts_for_merging[0]['age_str']}"
404
+ current_image_crops_with_details.append((f"Global Br眉ste (beide)", resize_crop(merged_breast_crop, TARGET_MAX_DIMENSION), desc))
405
  else:
406
  b_data = global_breasts_for_merging[0]
407
  crop = original_img.crop(b_data['bbox'])
 
556
  )
557
 
558
  if __name__ == "__main__":
559
+ interface.launch(debug=False, share=True)