Skip to content

Commit

Permalink
Merge pull request #208 from hotosm/fix/testing-issues
Browse files Browse the repository at this point in the history
Implementing the HUBs feedback
  • Loading branch information
omranlm authored Feb 1, 2024
2 parents a496b73 + a2d27a2 commit 281e69e
Show file tree
Hide file tree
Showing 9 changed files with 294 additions and 44 deletions.
1 change: 1 addition & 0 deletions backend/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ class FeedbackLabelViewset(viewsets.ModelViewSet):
bbox_filter_field = "geom"
filter_backends = (
InBBoxFilter, # it will take bbox like this api/v1/label/?in_bbox=-90,29,-89,35 ,
DjangoFilterBackend
)
bbox_filter_include_overlapping = True
filterset_fields = ["feedback_aoi", "feedback_aoi__training"]
Expand Down
Binary file added frontend/public/josm-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 9 additions & 4 deletions frontend/src/components/Layout/Feedback/Feedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,14 @@ const Feedback = (props) => {
} else {
const datasetId = res.data.dataset;
setDatasetId(datasetId);
const resAOIs = await axios.get(`/aoi/?dataset=${datasetId}`, null, {
headers,
});
const resAOIs = await axios.get(
`/workspace/download/dataset_${datasetId}/output/training_${trainingId}/aois.geojson`,
null,
{
headers,
}
);
// console.log("resAOIs", resAOIs);
setOriginalAOIs(resAOIs.data);
}
} catch (e) {
Expand Down Expand Up @@ -247,7 +252,7 @@ const Feedback = (props) => {
"access-token": accessToken,
};
const res = await axios.get(
`/feedback-label/?in_bbox=${box._southWest.lng},${box._southWest.lat},${box._northEast.lng},${box._northEast.lat}`,
`/feedback-label/?in_bbox=${box._southWest.lng},${box._southWest.lat},${box._northEast.lng},${box._northEast.lat}&feedback_aoi__training=${trainingId}`,
{ headers }
);
console.log("res from getLabels ", res);
Expand Down
99 changes: 85 additions & 14 deletions frontend/src/components/Layout/Feedback/FeedbackAOI.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useContext, useEffect, useState } from "react";
import {
Alert,
Avatar,
Grid,
IconButton,
Expand All @@ -9,6 +10,7 @@ import {
ListItemSecondaryAction,
ListItemText,
Pagination,
Snackbar,
SvgIcon,
Typography,
} from "@mui/material";
Expand Down Expand Up @@ -43,6 +45,8 @@ const ListItemWithWiderSecondaryAction = withStyles({
const PER_PAGE = 5;
const FeedbackAOI = (props) => {
const [dense, setDense] = useState(true);
const [openSnack, setOpenSnack] = useState(false);

const getFeedbackAOIs = async () => {
try {
const res = await axios.get(
Expand Down Expand Up @@ -179,7 +183,7 @@ const FeedbackAOI = (props) => {
<>
Area seems to be very small for an AOI
<br />
Make sure it is not a Label
Please delete it and create a bigger AOI
</>
) : (
""
Expand All @@ -203,23 +207,64 @@ const FeedbackAOI = (props) => {
aria-label="comments"
sx={{ width: 24, height: 24 }}
className="margin1 transparent"
onClick={(e) => {
const url = `https://rapideditor.org/rapid#background=${
props.sourceImagery
? "custom:" + props.sourceImagery
: "Bing"
}&datasets=fbRoads,msBuildings&disable_features=boundaries&map=16.00/17.9253/120.4841&gpx=&gpx=https://fair-dev.hotosm.org/api/v1/feedback-aoi/gpx/${
layer.id
}`;
console.log(url);
window.open(url, "_blank", "noreferrer");
onClick={async (e) => {
try {
// mutateFetch(layer.aoiId);
console.log("layer", layer);
console.log(
" props.sourceImagery",
props.sourceImagery
);

const Imgurl = new URL(
"http://127.0.0.1:8111/imagery"
);
Imgurl.searchParams.set("type", "tms");
Imgurl.searchParams.set("title", "Imagery");
Imgurl.searchParams.set(
"url",
props.sourceImagery
);
const imgResponse = await fetch(Imgurl);
// bounds._southWest.lng,
// bounds._southWest.lat,
// bounds._northEast.lng,
// bounds._northEast.lat,
const loadurl = new URL(
"http://127.0.0.1:8111/load_and_zoom"
);
loadurl.searchParams.set(
"bottom",
layer.geometry.coordinates[0][0][1]
);
loadurl.searchParams.set(
"top",
layer.geometry.coordinates[0][1][1]
);
loadurl.searchParams.set(
"left",
layer.geometry.coordinates[0][0][0]
);
loadurl.searchParams.set(
"right",
layer.geometry.coordinates[0][2][0]
);
const loadResponse = await fetch(loadurl);

if (!imgResponse.ok) {
setOpenSnack(true);
}
} catch (error) {
console.log("error", error);
setOpenSnack(true);
}
}}
>
{/* <MapTwoTone /> */}
<img
alt="RapiD logo"
className="rapid-logo-small"
src="/rapid-logo.png"
alt="JOSM logo"
className="editor-logo-small"
src="/josm-logo.png"
/>
</IconButton>
</Tooltip>
Expand Down Expand Up @@ -319,6 +364,32 @@ const FeedbackAOI = (props) => {
</Typography>
)}
</Grid>
<Snackbar
open={openSnack}
autoHideDuration={5000}
onClose={() => {
console.log("openSnack", openSnack);
setOpenSnack(false);
}}
message={
<Alert severity="error">
<span>
Please make sure JOSM is open and Remote Control feature is
enabled{" "}
<a
target="_blank"
rel="noreferrer"
href="https://josm.openstreetmap.de/wiki/Help/Preferences/RemoteControl"
>
Click here for more details
</a>
</span>
</Alert>
}
// action={action}
color="red"
anchorOrigin={{ vertical: "bottom", horizontal: "right" }}
/>
</>
);
};
Expand Down
16 changes: 8 additions & 8 deletions frontend/src/components/Layout/Learn/Learn.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,56 +128,56 @@ const Learn = () => {
title: "Step 16: Create Training for Your Model",
description:
"After creating Model for your dataset you will see following page. From here You can submit Trainings for your model. Give your epochs , Batch size and Zoom level for Training . Epochs refers to the number of times the learning algorithm will go through the entire training dataset, recommended between 20 - 60. Batch size refers to number of sample pairs to work through before updating the internal model parameters. 8 is recommended and preferred to be 8, 16, 32 ...etc . Zoom levels are the image sizes that will be downloaded during trainings (20 is recommended ) You can train on all of zoom levels . you can play with the parameters for your training after visualizing your results , Increase- Decrease batchsize / epochs or your training labels to achieve best performing model , You can Use Goldilocks Method to find best parameter for your dataset",
image: "/learn/15.png", // Add image URL here
image: "/learn-resources/15.png", // Add image URL here
},
{
id: 17,
title: "Step 17: Submit Your Training",
description:
"Click on Submit Training Request and slide down, you will see your training listed there , You can check its status by clicking on info, Based on your dataset , AOI , your parameter model training may take time you can check progress on status. SUBMITTED , RUNNING , FINISHED . You can see your model accuracy and use it after it is finished. If it fails you can check the reason for it and adapt accordingly",
image: "/learn/16.png", // Add image URL here
image: "/learn-resources/16.png", // Add image URL here
},
{
id: 18,
title: "Step 18: Check info of your Trainings",
description:
"Click on i icon button next to your training to visualize current terminal and process of your training , It will display accuracy validation graph after training is finished",
image: "/learn/17.png", // Add image URL here
image: "/learn-resources/17.png", // Add image URL here
},
{
id: 19,
title: "Step 19: Finished Training",
description:
"You can visualize your trainings accuracy and it's graph after it is finished like this",
image: "/learn/18.png", // Add image URL here
image: "/learn-resources/18.png", // Add image URL here
},
{
id: 20,
title: "Step 20: Publish Your Training",
description:
"Once you are statisfied accuracy and want to visualize its prediction you need to publish the training. You can run multiple trainings for same model to find best performing checkpoint, Each training will result different checkpoint. You can always publish another training. Click on PUblish Training button to Publish Model",
image: "/learn/19.png", // Add image URL here
image: "/learn-resources/19.png", // Add image URL here
},
{
id: 21,
title: "Step 21: Start Mapping",
description:
"Once Model is Published it will be listed here on Model page as Published Training ID , Click on Start Mapping to See its Prediction",
image: "/learn/20.png", // Add image URL here
image: "/learn-resources/20.png", // Add image URL here
},
{
id: 22,
title: "Step 22: Visualize Your Model's Prediction",
description:
"Zoom to the area you want to see predictions and Click Detect to Run your Published training Model. It will load the model and Run live predictions ",
image: "/learn/21.png", // Add image URL here
image: "/learn-resources/21.png", // Add image URL here
},
{
id: 23,
title: "Step 23: Bring Predictions to OSM",
description:
"Your Predictions will be visualized on Map, Now you can bring them to OSM Modify them remove bad predictions and Push it back to OSM. fAIr should be able to have feedback loop when user discards the prediction or modifies it ( it is work in Prrogress) , you can launch JOSM with prediction data though",
image: "/learn/22.png", // Add image URL here
image: "/learn-resources/22.png", // Add image URL here
},
];

Expand Down
Loading

0 comments on commit 281e69e

Please sign in to comment.