Skip to content

Commit

Permalink
Merge pull request #305 from hotosm/feature/yolo
Browse files Browse the repository at this point in the history
Feature : YOLO Support
  • Loading branch information
kshitijrajsharma authored Nov 25, 2024
2 parents 88aaac5 + e526d30 commit 3ba5b23
Show file tree
Hide file tree
Showing 11 changed files with 489 additions and 292 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docker_publish_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ env:

jobs:
build-and-push-api-image:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
permissions:
contents: read
packages: write
Expand Down Expand Up @@ -50,7 +50,7 @@ jobs:

build-and-push-worker-image:
needs: build-and-push-api-image
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
permissions:
contents: read
packages: write
Expand Down
2 changes: 1 addition & 1 deletion backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ RUN pip install setuptools==68.2.2
RUN pip install wheel==0.41.3
RUN pip install build==1.0.0

RUN pip install -r requirements.txt
RUN pip install -r requirements.txt

# RUN pip install --use-deprecated=legacy-resolver -r requirements.txt
COPY docker/ramp/solaris /tmp/solaris
Expand Down
5 changes: 5 additions & 0 deletions backend/aiproject/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@
RAMP_HOME = env("RAMP_HOME", default=None)
if RAMP_HOME:
os.environ["RAMP_HOME"] = RAMP_HOME
YOLO_HOME = env("YOLO_HOME")


# training workspace
TRAINING_WORKSPACE = env(
Expand All @@ -224,4 +226,7 @@
ENABLE_PREDICTION_API = env("ENABLE_PREDICTION_API", default=False)


LOG_LINE_STREAM_TRUNCATE_VALUE = env("LOG_LINE_STREAM_TRUNCATE_VALUE", default=10)


TEST_RUNNER = "tests.test_runners.NoDestroyTestRunner"
4 changes: 2 additions & 2 deletions backend/api-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ validators==0.20.0
gpxpy==1.5.0
geojson2osm==0.0.1
osmconflator==0.0.11
orthogonalizer==0.0.4
fairpredictor==0.0.26
# orthogonalizer==0.0.4
fairpredictor==0.0.37

rasterio==1.3.8
numpy<2.0.0
Expand Down
12 changes: 7 additions & 5 deletions backend/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class DatasetStatus(models.IntegerChoices):
ACTIVE = 0
DRAFT = -1

name = models.CharField(max_length=255)
name = models.CharField(max_length=50)
user = models.ForeignKey(OsmUser, to_field="osm_id", on_delete=models.CASCADE)
last_modified = models.DateTimeField(auto_now=True)
created_at = models.DateTimeField(auto_now_add=True)
Expand All @@ -36,6 +36,7 @@ class DownloadStatus(models.IntegerChoices):
label_fetched = models.DateTimeField(null=True, blank=True)
created_at = models.DateTimeField(auto_now_add=True)
last_modified = models.DateTimeField(auto_now=True)
user = models.ForeignKey(OsmUser, to_field="osm_id", on_delete=models.CASCADE)


class Label(models.Model):
Expand All @@ -49,24 +50,25 @@ class Label(models.Model):
class Model(models.Model):
BASE_MODEL_CHOICES = (
("RAMP", "RAMP"),
("YOLO", "YOLO"),
("YOLO_V8_V1", "YOLO_V8_V1"),
("YOLO_V8_V2", "YOLO_V8_V2"),
)

class ModelStatus(models.IntegerChoices):
ARCHIVED = 1
PUBLISHED = 0
DRAFT = -1

dataset = models.ForeignKey(Dataset, to_field="id", on_delete=models.CASCADE)
name = models.CharField(max_length=255)
dataset = models.ForeignKey(Dataset, to_field="id", on_delete=models.DO_NOTHING)
name = models.CharField(max_length=50)
created_at = models.DateTimeField(auto_now_add=True)
last_modified = models.DateTimeField(auto_now=True)
description = models.TextField(max_length=500, null=True, blank=True)
user = models.ForeignKey(OsmUser, to_field="osm_id", on_delete=models.CASCADE)
published_training = models.PositiveIntegerField(null=True, blank=True)
status = models.IntegerField(default=-1, choices=ModelStatus.choices)
base_model = models.CharField(
choices=BASE_MODEL_CHOICES, default="RAMP", max_length=10
choices=BASE_MODEL_CHOICES, default="RAMP", max_length=50
)


Expand Down
13 changes: 13 additions & 0 deletions backend/core/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,21 @@ class Meta:
"last_modified",
"label_fetched",
"label_status",
"user",
)

def create(self, validated_data):
request = self.context.get("request")
if request and hasattr(request, "user"):
validated_data["user"] = request.user
return super().create(validated_data)

def update(self, instance, validated_data):
request = self.context.get("request")
if request and hasattr(request, "user"):
validated_data["user"] = request.user
return super().update(instance, validated_data)


class FeedbackAOISerializer(GeoFeatureModelSerializer):
class Meta:
Expand Down
Loading

0 comments on commit 3ba5b23

Please sign in to comment.