-
Notifications
You must be signed in to change notification settings - Fork 19
AJP-3 introduce AI predictions #136
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
base: master
Are you sure you want to change the base?
Changes from all commits
f5b285f
4374b3c
d696a6f
75d0dbe
100aaed
2687ee0
2789323
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Generated by Django 3.2.7 on 2023-12-30 22:26 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('ajapaik', '0025_importblacklist'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='PhotoModelSuggestionResult', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('created', models.DateTimeField(auto_now_add=True, db_index=True)), | ||
('viewpoint_elevation', models.PositiveSmallIntegerField(blank=True, choices=[(0, 'Ground'), (1, 'Raised'), (2, 'Aerial')], null=True, verbose_name='Viewpoint elevation')), | ||
('scene', models.PositiveSmallIntegerField(blank=True, choices=[(0, 'Interior'), (1, 'Exterior')], null=True, verbose_name='Scene')), | ||
('photo', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='ajapaik.photo')), | ||
], | ||
options={ | ||
'abstract': False, | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name='PhotoModelSuggestionAlternativeCategory', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('created', models.DateTimeField(auto_now_add=True, db_index=True)), | ||
('viewpoint_elevation', models.PositiveSmallIntegerField(blank=True, choices=[(0, 'Ground'), (1, 'Raised'), (2, 'Aerial')], null=True, verbose_name='Viewpoint elevation')), | ||
('scene', models.PositiveSmallIntegerField(blank=True, choices=[(0, 'Interior'), (1, 'Exterior')], null=True, verbose_name='Scene')), | ||
('photo', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='ajapaik.photo')), | ||
('proposer', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='photo_scene_suggestions_alternation', to='ajapaik.profile')), | ||
], | ||
), | ||
migrations.AddConstraint( | ||
model_name='photomodelsuggestionalternativecategory', | ||
constraint=models.UniqueConstraint(condition=models.Q(('scene__isnull', True)), fields=('proposer', 'viewpoint_elevation'), name='unique_proposer_viewpoint_elevation_without_scene'), | ||
), | ||
migrations.AddConstraint( | ||
model_name='photomodelsuggestionalternativecategory', | ||
constraint=models.UniqueConstraint(condition=models.Q(('viewpoint_elevation__isnull', True)), fields=('proposer', 'scene'), name='unique_proposer_scene_without_viewpoint_elevation'), | ||
), | ||
] |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,4 +1,5 @@ | ||||||
function submitCategorySuggestion(photoIds, isMultiSelect) { | ||||||
sendCategorySuggestionToAI(photoIds, scene, viewpointElevation) | ||||||
$('#ajp-loading-overlay').show(); | ||||||
return fetch(photoSceneUrl, { | ||||||
method: 'POST', | ||||||
|
@@ -99,3 +100,100 @@ function clickSceneCategoryButton(buttonId) { | |||||
$('#' + buttonId).removeClass('btn-outline-dark'); | ||||||
$('#' + buttonId).removeClass('btn-light'); | ||||||
} | ||||||
|
||||||
function displaySmallAIIcon(categoryMap) { | ||||||
let scene = categoryMap["scene"] | ||||||
let viewpointElevation = categoryMap["viewpoint_elevation"] | ||||||
|
||||||
if (scene === "exterior") { | ||||||
$("#exterior-ai").show(); | ||||||
} | ||||||
if (scene === "interior") { | ||||||
$("#interior-ai").show(); | ||||||
} | ||||||
if (viewpointElevation === "ground") { | ||||||
$("#ground-ai").show(); | ||||||
} | ||||||
if (viewpointElevation === "aerial") { | ||||||
$("#aerial-ai").show(); | ||||||
} | ||||||
if (viewpointElevation === "raised") { | ||||||
$("#raised-ai").show(); | ||||||
} | ||||||
} | ||||||
|
||||||
function determinePictureCategory(jsonData) { | ||||||
let modelCategory = {}; | ||||||
if (jsonData && jsonData.length > 0) { | ||||||
let fields = jsonData[0].fields; | ||||||
if (fields && "scene" in fields) { | ||||||
if (fields["scene"] === 0) { | ||||||
modelCategory["scene"] = "interior"; | ||||||
} else { | ||||||
modelCategory["scene"] = "exterior"; | ||||||
} | ||||||
} | ||||||
if (fields && "viewpoint_elevation" in fields) { | ||||||
if (fields["viewpoint_elevation"] === 0) { | ||||||
modelCategory["viewpoint_elevation"] = "ground"; | ||||||
} else if (fields["viewpoint_elevation"] === 1) { | ||||||
modelCategory["viewpoint_elevation"] = "raised"; | ||||||
} else if (fields["viewpoint_elevation"] === 2) { | ||||||
modelCategory["viewpoint_elevation"] = "aerial"; | ||||||
} | ||||||
} | ||||||
} | ||||||
return modelCategory; | ||||||
} | ||||||
|
||||||
function markButtonsWithCategories(scene, viewpointElevation) { | ||||||
if (scene === "exterior") { | ||||||
clickSceneCategoryButton('exterior-button'); | ||||||
} | ||||||
if (scene === "interior") { | ||||||
clickSceneCategoryButton('interior-button'); | ||||||
} | ||||||
if (viewpointElevation === "ground") { | ||||||
clickViewpointElevationCategoryButton('ground-button'); | ||||||
} | ||||||
if (viewpointElevation === "aerial") { | ||||||
clickViewpointElevationCategoryButton('aerial-button'); | ||||||
} | ||||||
if (viewpointElevation === "raised") { | ||||||
clickViewpointElevationCategoryButton('raised-button'); | ||||||
} | ||||||
} | ||||||
|
||||||
function sendCategorySuggestionToAI(photoIds, scene, viewpointElevation) { | ||||||
let sceneVerdict = scene.toLowerCase(); | ||||||
let viewpointElevationVerdict = viewpointElevation.toLowerCase(); | ||||||
|
||||||
let payload = { | ||||||
"photo_id": photoIds[0] | ||||||
}; | ||||||
|
||||||
if (sceneVerdict === "interior") { | ||||||
payload["scene_to_alternate"] = 0 | ||||||
} | ||||||
if (sceneVerdict === "exterior") { | ||||||
payload["scene_to_alternate"] = 1 | ||||||
} | ||||||
if (viewpointElevationVerdict === "ground") { | ||||||
payload["viewpoint_elevation_to_alternate"] = 0 | ||||||
} | ||||||
if (viewpointElevationVerdict === "raised") { | ||||||
payload["viewpoint_elevation_to_alternate"] = 1 | ||||||
} | ||||||
if (viewpointElevationVerdict === "raised") { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
payload["viewpoint_elevation_to_alternate"] = 2 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to clarify, do we need to check for === "raised" twice? In any case, that would mean the value is always 2 - if it is raised. |
||||||
} | ||||||
|
||||||
postRequest( | ||||||
'/object-categorization/confirm-latest-category', | ||||||
payload, | ||||||
constants.translations.queries.POST_CATEGORY_CONFIRMATION_SUCCESS, | ||||||
constants.translations.queries.POST_CATEGORY_CONFIRMATION_FAILED, | ||||||
function () { | ||||||
} | ||||||
); | ||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually we have used
else if
- is there a risk that scene can be null, but we handle it asexterior
or do we need a fallback value (exterior) here?