BLUR-21
This commit is contained in:
parent
0bab6a7dd6
commit
b6dc97e6c6
@ -2,7 +2,6 @@
|
||||
import asyncio
|
||||
from blurme.templates import template
|
||||
from blurme.state import State
|
||||
|
||||
import reflex as rx
|
||||
|
||||
|
||||
@ -10,6 +9,7 @@ color = "rgb(107,99,246)"
|
||||
|
||||
@template(route="/settings", title="Zdjęcie", image = "/image-icon.png")
|
||||
def settings() -> rx.Component:
|
||||
|
||||
return rx.vstack(
|
||||
rx.heading("BlurMe", font_size="3em", margin_bottom="25px", background_image="linear-gradient(271.68deg, #7566fe 0.75%, #f96caf 88.52%)", background_clip="text", padding = "10px"),
|
||||
rx.text("Dodaj zdjęcie, które chcesz zanonimizować", font_size="1.2em"),
|
||||
@ -42,6 +42,7 @@ def settings() -> rx.Component:
|
||||
on_click=lambda img_name=img: State.delete_image(img_name), color="rgba(255, 75, 42,255)",
|
||||
width = "125px"),
|
||||
rx.button("Anonimizuj",
|
||||
on_click=lambda img_name=img: State.image_anonymization(img_name),
|
||||
width = "125px"),
|
||||
rx.button("Pobierz",
|
||||
on_click=lambda img_name=img: State.download_image(img_name),
|
||||
|
@ -1,9 +1,13 @@
|
||||
"""Base state for the app."""
|
||||
|
||||
import reflex as rx
|
||||
import os
|
||||
from blurme import styles
|
||||
import asyncio
|
||||
|
||||
from graphics.image_modification import blur_boxes_on_image
|
||||
from ml.element_detection import BoundBox, detect
|
||||
|
||||
class State(rx.State):
|
||||
"""The app state."""
|
||||
|
||||
@ -43,6 +47,18 @@ class State(rx.State):
|
||||
print(self.img)
|
||||
return rx.download(url=f'/{img_name}', filename=img_name)
|
||||
|
||||
async def image_anonymization(self, img_name: str):
|
||||
if img_name in self.img:
|
||||
image_path = rx.get_asset_path(img_name)
|
||||
new_img_name = "anonim-" + img_name
|
||||
new_image_path = rx.get_asset_path(new_img_name)
|
||||
blur_boxes_on_image(image_path, detect(image_path), new_image_path)
|
||||
upload_file = rx.UploadFile(file=open(new_image_path, 'rb'), filename=new_img_name)
|
||||
self.delete_image(img_name)
|
||||
await self.handle_upload([upload_file])
|
||||
self.img=self.img
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -4,7 +4,7 @@ from typing import List
|
||||
from PIL import Image, ImageDraw, ImageFont, ImageFilter
|
||||
from PIL.Image import composite
|
||||
|
||||
from BlurMe.ml.element_detection import BoundBox
|
||||
from ml.element_detection import BoundBox
|
||||
|
||||
DIR_PATH = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import unittest
|
||||
from unittest.mock import Mock, patch
|
||||
from element_detection import detect, BoundBox
|
||||
from BlurMe.graphics.image_modification import show_image_with_boxes
|
||||
from graphics.image_modification import show_image_with_boxes
|
||||
|
||||
|
||||
class TestYourModule(unittest.TestCase):
|
||||
|
Loading…
Reference in New Issue
Block a user