mahan_ym commited on
Commit
8b98658
·
1 Parent(s): 79b337b

privacy docs update. update readme

Browse files
Files changed (3) hide show
  1. README.md +8 -11
  2. src/modal_app.py +1 -1
  3. src/tools.py +4 -2
README.md CHANGED
@@ -14,8 +14,12 @@ short_description: 'Alfred of Images: An MCP server to handle your image edits.'
14
  ---
15
 
16
  <div align="center">
 
17
  <img src="./src/assets/icons/ImageAlfredIcon.png" alt="ImageAlfred" width=200 height=200>
18
 
 
 
 
19
  <h1>Image Alfred</h1>
20
 
21
  ImageAlfred is an image Model Context Protocol (MCP) tool designed to streamline image processing workflows
@@ -26,16 +30,8 @@ ImageAlfred is an image Model Context Protocol (MCP) tool designed to streamline
26
 
27
  <a href=https://huggingface.co> <img src="src/assets/icons/hf-logo.svg" alt="huggingface" height=40> </a>
28
  <a href="https://www.python.org"><img src="src/assets/icons/python-logo-only.svg" alt="python" height=40></a>
29
- <!-- <a href="https://www.gradio.app" heigh=40><img src="src/assets/icons/gradio-color.svg"></a> -->
30
  </div>
31
 
32
- <!-- It provides a user-friendly interface for interacting with image models, leveraging the power of Gradio for the frontend and Modal for scalable backend deployment. -->
33
-
34
- <!-- ## Features
35
- - Intuitive web interface for image processing
36
- - Powered by Gradio for rapid prototyping and UI
37
- - Scalable and serverless execution with Modal
38
- - Easily extendable for custom image models and workflows -->
39
 
40
  ## Maintainers
41
 
@@ -45,10 +41,11 @@ ImageAlfred is an image Model Context Protocol (MCP) tool designed to streamline
45
 
46
  ## Tools
47
 
48
- - [Gradio](https://www.gradio.app/): Serving user interface and MCP server
49
  - [Modal.com](https://modal.com/): AI infrastructure making all the magic 🔮 possible.
50
- - [SAM](https://segment-anything.com/): Segment Anything model by meta for image segmentation and mask generation
51
- - [CLIPSeg](https://github.com/timojl/clipseg): Image Segmentation using CLIP. We used it as a more precise object detection model
 
52
  - [HuggingFace](https://huggingface.co/): Downloading SAM and using Space for hosting.
53
 
54
  ## Getting Started
 
14
  ---
15
 
16
  <div align="center">
17
+ <a href="https://github.com/mahan-ym/ImageAlfred">
18
  <img src="./src/assets/icons/ImageAlfredIcon.png" alt="ImageAlfred" width=200 height=200>
19
 
20
+ <span><img src="https://img.shields.io/badge/GitHub-100000?style=for-the-badge&logo=github&logoColor=white"></span>
21
+
22
+ </a>
23
  <h1>Image Alfred</h1>
24
 
25
  ImageAlfred is an image Model Context Protocol (MCP) tool designed to streamline image processing workflows
 
30
 
31
  <a href=https://huggingface.co> <img src="src/assets/icons/hf-logo.svg" alt="huggingface" height=40> </a>
32
  <a href="https://www.python.org"><img src="src/assets/icons/python-logo-only.svg" alt="python" height=40></a>
 
33
  </div>
34
 
 
 
 
 
 
 
 
35
 
36
  ## Maintainers
37
 
 
41
 
42
  ## Tools
43
 
44
+ - [Gradio](https://www.gradio.app/): Serving user interface and MCP server.
45
  - [Modal.com](https://modal.com/): AI infrastructure making all the magic 🔮 possible.
46
+ - [SAM](https://segment-anything.com/): Segment Anything model by meta for image segmentation and mask generation.
47
+ - [CLIPSeg](https://github.com/timojl/clipseg): Image Segmentation using CLIP. We used it as a more precise object detection model.
48
+ - [OWLv2](https://huggingface.co/google/owlv2-large-patch14-ensemble): Zero-Shot object detection (Better performance in license plate detection and privacy preserving use-cases)
49
  - [HuggingFace](https://huggingface.co/): Downloading SAM and using Space for hosting.
50
 
51
  ## Getting Started
src/modal_app.py CHANGED
@@ -530,7 +530,7 @@ def apply_mosaic_with_bool_mask(
530
  )
531
  def preserve_privacy(
532
  image_pil: Image.Image,
533
- prompts: str,
534
  privacy_strength: int = 15,
535
  threshold: float = 0.2,
536
  ) -> Image.Image:
 
530
  )
531
  def preserve_privacy(
532
  image_pil: Image.Image,
533
+ prompts: list[str],
534
  privacy_strength: int = 15,
535
  threshold: float = 0.2,
536
  ) -> Image.Image:
src/tools.py CHANGED
@@ -52,7 +52,7 @@ def privacy_preserve_image(
52
 
53
  Args:
54
  input_img: Input image or can be URL string of the image or base64 string. Cannot be None.
55
- input_prompt (str): Object to obscure in the image. It can be a single word or multiple words, e.g., "left person face", "license plate".
56
  privacy_strength (int): Strength of the privacy preservation effect. Higher values result in stronger blurring. Default is 15.
57
  threshold (float): Model threshold for detecting objects. It should be between 0.01 and 0.99. Default is 0.2. for detecting smaller objects, small regions or faces a lower threshold is recommended.
58
  Returns:
@@ -67,11 +67,13 @@ def privacy_preserve_image(
67
  raise gr.Error("Input prompt cannot be None or empty.")
68
  if threshold < 0.01 or threshold > 0.99:
69
  raise gr.Error("Threshold must be between 0.01 and 0.99.")
 
 
70
 
71
  func = modal.Function.from_name(modal_app_name, "preserve_privacy")
72
  output_pil = func.remote(
73
  image_pil=input_img,
74
- prompts=input_prompt,
75
  privacy_strength=privacy_strength,
76
  threshold=threshold,
77
  )
 
52
 
53
  Args:
54
  input_img: Input image or can be URL string of the image or base64 string. Cannot be None.
55
+ input_prompt (str): Object to obscure in the image has to be a dot-separated string. It can be a single word or multiple words, e.g., "left person face", "license plate" but it must be as short as possible and avoid using symbols or punctuation. e.g. input_prompt = "face. right car. blue shirt."
56
  privacy_strength (int): Strength of the privacy preservation effect. Higher values result in stronger blurring. Default is 15.
57
  threshold (float): Model threshold for detecting objects. It should be between 0.01 and 0.99. Default is 0.2. for detecting smaller objects, small regions or faces a lower threshold is recommended.
58
  Returns:
 
67
  raise gr.Error("Input prompt cannot be None or empty.")
68
  if threshold < 0.01 or threshold > 0.99:
69
  raise gr.Error("Threshold must be between 0.01 and 0.99.")
70
+ if isinstance(input_prompt, str):
71
+ prompts = [prompt.strip() for prompt in input_prompt.split(".")]
72
 
73
  func = modal.Function.from_name(modal_app_name, "preserve_privacy")
74
  output_pil = func.remote(
75
  image_pil=input_img,
76
+ prompts=prompts,
77
  privacy_strength=privacy_strength,
78
  threshold=threshold,
79
  )