Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changed summmary.py logic #121

Merged
merged 32 commits into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
d21160d
changed summmary.py logic
piterand Jun 21, 2023
a3b799e
fixing test_summary
piterand Jun 21, 2023
aa6ed41
added macos for testing
piterand Jun 21, 2023
f2fee74
fixed_display_test
piterand Jun 21, 2023
8ab9139
fixed docs and exceptions
piterand Jun 22, 2023
5bdf325
fixed code smells
piterand Jun 22, 2023
0beb9c5
main merge
piterand Jun 22, 2023
19fee20
main merge 2
piterand Jun 22, 2023
6435f82
Merge branch 'main' into summary_fixing
piterand Jun 23, 2023
d642c8e
fixed code smells
piterand Jun 23, 2023
e4aa158
adding dropout menu for summary
piterand Jun 23, 2023
14e8147
added new SummaryDetector to AnalysisExplorer
piterand Jun 23, 2023
0100b67
bug fixing
piterand Jun 23, 2023
978c836
code improving
piterand Jun 23, 2023
05725d9
fixed test_display
piterand Jun 23, 2023
9559a7b
fixed code smells
piterand Jun 23, 2023
c84be2a
reduce tests for macos
iulusoy Jun 26, 2023
59fb515
try different tqdm version
iulusoy Jun 26, 2023
fd985a6
disabled MacOS CI testing
piterand Jun 26, 2023
884d2db
enable tests again; don't run on macos
iulusoy Jun 26, 2023
0dcc0a6
more tests and exceptions for init
iulusoy Jun 26, 2023
9ff20b5
reduce number of tests
iulusoy Jun 26, 2023
07f2a2c
put some tests in again
iulusoy Jun 26, 2023
23af428
changed CI, runs pytest independently
piterand Jun 26, 2023
d094809
added not gcv flag for pytest test/test_text.py command in CI
piterand Jun 26, 2023
0e911e0
added not long flag to CI tests
piterand Jun 26, 2023
332b344
added macos to CI and disable long test in multimodal_search
piterand Jun 26, 2023
e91a462
exclude test_analysisExplorer from macos in CI
piterand Jun 26, 2023
17a1804
Exclude another test from macos
piterand Jun 26, 2023
a4ab433
Exclude another 3 tests from macos
piterand Jun 26, 2023
f29a01c
moved some tests from test_init_summary to test_advanced_init_summary…
piterand Jun 26, 2023
54d86f9
Merge remote-tracking branch 'origin' into summary_fixing
piterand Jun 26, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 32 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,42 @@ jobs:
run: |
python -m pip install --upgrade pip
python -m pip install -e .
- name: Run pytest linux (linux-only)
if: matrix.os == 'ubuntu-22.04'
- name: Run pytest test_colors
run: |
cd ammico
python -m pytest -m "not gcv and not long" -svv --cov=. --cov-report=xml
- name: Run pytest windows(windows-only)
if: matrix.os == 'windows-latest'
python -m pytest test/test_colors.py -svv --cov=. --cov-report=xml
- name: Run pytest test_cropposts
run: |
cd ammico
python -m pytest -m "not gcv and not long and not win_skip" -svv --cov=. --cov-report=xml
python -m pytest test/test_cropposts.py -svv --cov=. --cov-report=xml
- name: Run pytest test_display
run: |
cd ammico
python -m pytest test/test_display.py -svv --cov=. --cov-report=xml
- name: Run pytest test_faces
run: |
cd ammico
python -m pytest test/test_faces.py -svv --cov=. --cov-report=xml
- name: Run pytest test_multimodal_search
run: |
cd ammico
python -m pytest test/test_multimodal_search.py -m "not long" -svv --cov=. --cov-report=xml
- name: Run pytest test_objects
run: |
cd ammico
python -m pytest test/test_objects.py -svv --cov=. --cov-report=xml
- name: Run pytest test_summary
run: |
cd ammico
python -m pytest test/test_summary.py -m "not long" -svv --cov=. --cov-report=xml
- name: Run pytest test_text
run: |
cd ammico
python -m pytest test/test_text.py -m "not gcv" -svv --cov=. --cov-report=xml
- name: Run pytest test_utils
run: |
cd ammico
python -m pytest test/test_utils.py -svv --cov=. --cov-report=xml
- name: Upload coverage
if: matrix.os == 'ubuntu-22.04' && matrix.python-version == '3.9'
uses: codecov/codecov-action@v3
Expand Down
83 changes: 79 additions & 4 deletions ammico/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
"CAM16-UCS",
"DIN99",
]
SUMMARY_ANALYSIS_TYPE = ["summary_and_questions", "summary", "questions"]
SUMMARY_MODEL = ["base", "large"]


class AnalysisExplorer:
Expand Down Expand Up @@ -111,13 +113,17 @@ def __init__(self, mydict: dict) -> None:
State("setting_Emotion_emotion_threshold", "value"),
State("setting_Emotion_race_threshold", "value"),
State("setting_Color_delta_e_method", "value"),
State("setting_Summary_analysis_type", "value"),
State("setting_Summary_model", "value"),
State("setting_Summary_list_of_questions", "value"),
prevent_initial_call=True,
)(self._right_output_analysis)

self.app.callback(
Output("settings_TextDetector", "style"),
Output("settings_EmotionDetector", "style"),
Output("settings_ColorDetector", "style"),
Output("settings_Summary_Detector", "style"),
Input("Dropdown_select_Detector", "value"),
)(self._update_detector_setting)

Expand Down Expand Up @@ -240,6 +246,60 @@ def _create_setting_layout(self):
)
],
),
html.Div(
id="settings_Summary_Detector",
style={"display": "none"},
children=[
html.Div(
[
dcc.Dropdown(
options=SUMMARY_ANALYSIS_TYPE,
value="summary_and_questions",
id="setting_Summary_analysis_type",
)
],
style={
"width": "33%",
"display": "inline-block",
},
),
html.Div(
[
dcc.Dropdown(
options=SUMMARY_MODEL,
value="base",
id="setting_Summary_model",
)
],
style={
"width": "33%",
"display": "inline-block",
"margin-top": "10px",
},
),
html.Div(
[
html.Div(
"Please enter a question",
style={
"height": "50px",
"margin-top": "5px",
},
),
dcc.Input(
type="text",
id="setting_Summary_list_of_questions",
style={"height": "auto", "margin-bottom": "auto"},
),
],
style={
"width": "33%",
"display": "inline-block",
"margin-top": "10px",
},
),
],
),
],
)
return settings_layout
Expand Down Expand Up @@ -334,16 +394,19 @@ def _update_detector_setting(self, setting_input):
}

if setting_input == "TextDetector":
return display_flex, display_none, display_none
return display_flex, display_none, display_none, display_none

if setting_input == "EmotionDetector":
return display_none, display_flex, display_none
return display_none, display_flex, display_none, display_none

if setting_input == "ColorDetector":
return display_none, display_none, display_flex
return display_none, display_none, display_flex, display_none

if setting_input == "SummaryDetector":
return display_none, display_none, display_none, display_flex

else:
return display_none, display_none, display_none
return display_none, display_none, display_none, display_none

def _right_output_analysis(
self,
Expand All @@ -355,6 +418,9 @@ def _right_output_analysis(
setting_emotion_emotion_threshold: int,
setting_emotion_race_threshold: int,
setting_color_delta_e_method: str,
setting_summary_analysis_type: str,
setting_summary_model: str,
setting_summary_list_of_questions: str,
) -> dict:
"""Callback function to perform analysis on the selected image and return the output.
Expand Down Expand Up @@ -396,6 +462,15 @@ def _right_output_analysis(
image_copy,
delta_e_method=setting_color_delta_e_method,
)
elif detector_value == "SummaryDetector":
detector_class = identify_function(
image_copy,
analysis_type=setting_summary_analysis_type,
summary_model_type=setting_summary_model,
list_of_questions=[setting_summary_list_of_questions]
if (setting_summary_list_of_questions is not None)
else None,
)
else:
detector_class = identify_function(image_copy)
return detector_class.analyse_image()
Loading