ev6 commited on
Commit
f204b14
·
verified ·
1 Parent(s): a76893e

Update app/apps/emotion_recognition/models.py

Browse files
app/apps/emotion_recognition/models.py CHANGED
@@ -1,34 +1,34 @@
1
- from django.db import models
2
- from PIL import Image
3
-
4
-
5
- # Create your models here.
6
- class UserImageRecognition(models.Model):
7
- uploaded_image = models.ImageField(null=False, blank=False)
8
- final_image = models.ImageField(null=True, blank=True)
9
- recognized_emotion = models.CharField(max_length=20,null=True, blank=True)
10
- predicted_emotions = models.CharField(max_length=155,null=True,blank=True)
11
- created_at = models.DateTimeField(
12
- auto_now_add=True, null=False, blank=False)
13
-
14
- STATUS_CHOICES = (
15
- ('PEN', 'Pending'),
16
- ('COM', 'Complete'),
17
- ('ERR', 'Error'),
18
- )
19
- status = models.CharField(
20
- max_length=3, choices=STATUS_CHOICES, null=False, blank=False, default='PEN')
21
-
22
- class Meta:
23
- ordering = ['-created_at']
24
-
25
- def save(self, *args, **kwargs):
26
- super().save(*args, **kwargs)
27
- uploaded_img = Image.open(self.uploaded_image.path)
28
- if uploaded_img.height > 400 or uploaded_img.width > 400:
29
- output_size = (400, 400)
30
- uploaded_img.thumbnail(output_size)
31
- uploaded_img.save(self.uploaded_image.path)
32
-
33
- def __str__(self):
34
- return f'{self.user} - {self.uploaded_image}'
 
1
+ from django.db import models
2
+ from PIL import Image
3
+
4
+
5
+ # Create your models here.
6
+ class UserImageRecognition(models.Model):
7
+ uploaded_image = models.ImageField(null=False, blank=False)
8
+ final_image = models.ImageField(null=True, blank=True)
9
+ recognized_emotion = models.CharField(max_length=20,null=True, blank=True)
10
+ predicted_emotions = models.CharField(max_length=155,null=True,blank=True)
11
+ created_at = models.DateTimeField(
12
+ auto_now_add=True, null=False, blank=False)
13
+
14
+ STATUS_CHOICES = (
15
+ ('PEN', 'Pending'),
16
+ ('COM', 'Complete'),
17
+ ('ERR', 'Error'),
18
+ )
19
+ status = models.CharField(
20
+ max_length=3, choices=STATUS_CHOICES, null=False, blank=False, default='PEN')
21
+
22
+ class Meta:
23
+ ordering = ['-created_at']
24
+
25
+ def save(self, *args, **kwargs):
26
+ super().save(*args, **kwargs)
27
+ uploaded_img = Image.open(self.uploaded_image.path)
28
+ if uploaded_img.height > 400 or uploaded_img.width > 400:
29
+ output_size = (400, 400)
30
+ uploaded_img.thumbnail(output_size)
31
+ uploaded_img.save(self.uploaded_image.path)
32
+
33
+ def __str__(self):
34
+ return f'{self.uploaded_image}'