Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/pip/requests-2.31.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jdede authored Aug 10, 2023
2 parents e89d754 + 9afa017 commit 431310f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
asgiref==3.6.0
certifi==2022.12.7
certifi==2023.7.22
charset-normalizer==3.1.0
Django==4.1.7
Django==4.1.10
docopt==0.6.2
idna==3.4
numpy==1.24.2
Pillow==9.4.0
pipreqs==0.4.11
requests==2.31.0
pipreqs==0.4.12
sqlparse==0.4.4
urllib3==1.26.15
yarg==0.1.9
yarg==0.1.9
22 changes: 18 additions & 4 deletions simplelabel/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,24 @@ class PollImageView(FormView):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)

pks = Image.objects.filter(image_dataset__dataset_active=True).values_list('pk', flat=True)
if len(pks) == 0:
raise Http404("No polls available yet. Please return later")
random_pk = random.choice(pks)
use_betavariate = True
random_pk = None

if use_betavariate:
pks = Image.objects.filter(image_dataset__dataset_active=True).annotate(num_polls=Count("poll")).order_by("num_polls").values_list('pk', flat=True)
if len(pks) == 0:
raise Http404("No polls available yet. Please return later")
# TODO: Maybe check the parameters. Should be a uniform
# distribution with a slightly higher probability towards low
# values (i.e. images with less polls).
random_pk = pks[round(random.betavariate(0.8, 1) * (len(pks)-1))]
else:
pks = Image.objects.filter(image_dataset__dataset_active=True).values_list('pk', flat=True)
if len(pks) == 0:
raise Http404("No polls available yet. Please return later")
random_pk = random.choice(pks)


random_img = Image.objects.get(pk=random_pk)

classes = Class.objects.filter(class_is_visible=True)
Expand Down
2 changes: 1 addition & 1 deletion tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ to an `.mp4` file:




Required libraries (venv)
=========================

Expand All @@ -25,6 +24,7 @@ a virtual environment (venv) using pip:
* imutils
* numpy
* opencv-python
* Pillow


Tools and their use cases
Expand Down

0 comments on commit 431310f

Please sign in to comment.