Compare commits

...

3 Commits

Author SHA1 Message Date
dba1d112d4 BLUR-32 sidebar modification 2023-12-05 13:16:15 +01:00
c89ff607df test image 2023-11-28 18:59:48 +01:00
bab438a456 test-1 2023-11-28 18:59:33 +01:00
5 changed files with 65 additions and 6 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 KiB

After

Width:  |  Height:  |  Size: 97 KiB

View File

@ -22,6 +22,7 @@ def sidebar_header() -> rx.Component:
width="100%", width="100%",
border_bottom=styles.border, border_bottom=styles.border,
padding="1em", padding="1em",
align = 'center',
) )
def sidebar_item(text: str, icon: str, url: str, ) -> rx.Component: def sidebar_item(text: str, icon: str, url: str, ) -> rx.Component:
@ -58,11 +59,11 @@ def sidebar_item(text: str, icon: str, url: str, ) -> rx.Component:
styles.accent_color, styles.accent_color,
"transparent", "transparent",
), ),
color=rx.cond( #color=rx.cond(
active, # active,
styles.accent_text_color, # styles.accent_text_color,
styles.text_color, # styles.text_color,
), #),
border_radius=styles.border_radius, border_radius=styles.border_radius,
box_shadow=styles.box_shadow, box_shadow=styles.box_shadow,
width="100%", width="100%",
@ -103,8 +104,8 @@ def sidebar() -> rx.Component:
padding="1em", padding="1em",
), ),
rx.spacer(), rx.spacer(),
#sidebar_footer(),
height="100em", height="100em",
), ),
display=["none", "none", "block"], display=["none", "none", "block"],
min_width=styles.sidebar_width, min_width=styles.sidebar_width,

View File

@ -6,6 +6,7 @@ border_radius = "0.375rem"
box_shadow = "0px 0px 0px 1px rgba(84, 82, 95, 0.14)" box_shadow = "0px 0px 0px 1px rgba(84, 82, 95, 0.14)"
border = "1px solid #F4F3F6" border = "1px solid #F4F3F6"
text_color = "black" text_color = "black"
text_color_dark = "white"
accent_text_color = "black" accent_text_color = "black"
accent_color = "linear-gradient(linear-gradient(43deg, rgba(201,238,248,1) 18%, rgba(253,210,227,0.7792366946778712) 86%)" accent_color = "linear-gradient(linear-gradient(43deg, rgba(201,238,248,1) 18%, rgba(253,210,227,0.7792366946778712) 86%)"
#linear-gradient(120deg, #d299c2 0%, #fef9d7 100%);" #linear-gradient(120deg, #d299c2 0%, #fef9d7 100%);"

BIN
ml/MicrosoftTeams-image.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

57
ml/test.py Normal file
View File

@ -0,0 +1,57 @@
import unittest
from unittest.mock import Mock, patch
from element_detection import detect, show_image_with_boxes, BoundBox
class TestYourModule(unittest.TestCase):
@patch('element_detection.FACES_MODEL.predict')
@patch('element_detection.PLATES_MODEL.predict')
def test_detect(self, mock_plates_predict, mock_faces_predict):
# Przygotuj dane testowe
image_path = 'blurme/ml/MicrosoftTeams-image.png'
mock_faces_predict.__iter__.return_value = [Mock(cpu=Mock(return_value=Mock(numpy=Mock(boxes=[Mock(xyxy=[1, 2, 3, 4])]))))]
mock_plates_predict.__iter__.return_value = [Mock(cpu=Mock(return_value=Mock(numpy=Mock(boxes=[Mock(xyxy=[5, 6, 7, 8])]))))]
# Wywołaj funkcję
result = detect(image_path)
# Sprawdź, czy otrzymałeś oczekiwany wynik
expected_result = [BoundBox(1, 2, 3, 4), BoundBox(5, 6, 7, 8)]
self.assertEqual(result, expected_result)
@patch('element_detection.ImageDraw.Draw')
@patch('element_detection.ImageFont.truetype')
#@patch('element_detection.Image.save')
@patch('element_detection.Image.open')
def test_show_image_with_boxes(self, mock_image_open,
#mock_image_save,
mock_truetype, mock_draw):
# Przygotuj dane testowe
in_image_path = 'blurme/ml/MicrosoftTeams-image.png'
bounding_boxes = [BoundBox(1, 2, 3, 4), BoundBox(5, 6, 7, 8)]
# Wywołaj funkcję
show_image_with_boxes(in_image_path, bounding_boxes)
# Sprawdź, czy odpowiednie metody zostały wywołane z oczekiwanymi argumentami
mock_image_open.assert_called_once_with(in_image_path)
mock_draw.assert_called_once()
# mock_image_save.assert_called_once()
if __name__ == '__main__':
unittest.main()
def test_detect_with_stub(self, mock_plates_predict, mock_faces_predict):
# Przygotuj dane testowe
image_path = 'blurme/ml/MicrosoftTeams-image.png'
mock_faces_predict.__iter__.return_value = [Mock(cpu=Mock(return_value=Mock(numpy=Mock(boxes=[Mock(xyxy=[1, 2, 3, 4])]))))]
mock_plates_predict.__iter__.return_value = [Mock(cpu=Mock(return_value=Mock(numpy=Mock(boxes=[Mock(xyxy=[5, 6, 7, 8])]))))]
# Użyj stuba zamiast rzeczywistego BoundBox
with patch('element_detection.BoundBox', StubBoundBox):
# Wywołaj funkcję
result = detect(image_path)
# Sprawdź, czy otrzymałeś oczekiwany wynik
expected_result = [StubBoundBox(1, 2, 3, 4), StubBoundBox(5, 6, 7, 8)]
self.assertEqual(result, expected_result)