Skip to content

Commit

Permalink
Updated
Browse files Browse the repository at this point in the history
  • Loading branch information
GBU31 committed Dec 4, 2023
1 parent 105a475 commit 3065bce
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 13 deletions.
File renamed without changes
File renamed without changes
2 changes: 1 addition & 1 deletion janus_ai/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
SECRET_KEY = 'django-insecure-766bec8h)4wk49djosnvis1=fyb0y=2qlef7(@et_-fq#72@to'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
DEBUG = True

ALLOWED_HOSTS = ['*']

Expand Down
5 changes: 3 additions & 2 deletions main/DeepFake/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,12 @@ def set_src_image(image):
indexes_triangles = get_triangles(convexhull=src_convexHull,
landmarks_points=src_landmark_points,
np_points=src_np_points)

i = 0
try:
set_src_image(image)

while True:
while i < 2:
i += 1
global src_image, src_image_gray, src_mask, src_landmark_points, src_np_points, src_convexHull, indexes_triangles

_, dest_image = cap.read()
Expand Down
6 changes: 3 additions & 3 deletions main/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.2 on 2023-04-14 09:57
# Generated by Django 4.0.3 on 2023-12-04 02:03

from django.db import migrations, models

Expand All @@ -15,8 +15,8 @@ class Migration(migrations.Migration):
name='FileModel',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('image', models.ImageField(upload_to='images/')),
('video', models.FileField(upload_to='videos/')),
('image_one', models.ImageField(upload_to='images/')),
('image_two', models.ImageField(upload_to='images_two/')),
],
),
]
4 changes: 2 additions & 2 deletions main/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.db import models

class FileModel(models.Model):
image = models.ImageField(upload_to='images/')
video = models.FileField(upload_to='videos/')
image_one = models.ImageField(upload_to='images/')
image_two = models.ImageField(upload_to='images_two/')
2 changes: 1 addition & 1 deletion main/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
class FileSerializer(serializers.ModelSerializer):
class Meta:
model = FileModel
fields = ['image', 'video']
fields = '__all__'
11 changes: 7 additions & 4 deletions main/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@ def upload_file(self, request):
serializer = FileSerializer(data=request.data)
if serializer.is_valid():
serializer.save()
os.system(f'python3 main/DeepFake/main.py videos/{str(request.data["video"])} images/{str(request.data["image"])} output/{random_string}.avi')
response = FileResponse(open('output/'+random_string + '.avi', 'rb'))
response['Content-Disposition'] = f'attachment; filename=output/"{random_string}.avi"'
os.system(f'rm -rf videos/{str(request.data["video"])} images/{str(request.data["image"])} output/{random_string}.avi')

os.system(f'python3 main/DeepFake/main.py images_two/{str(request.data["image_two"])} images/{str(request.data["image_one"])} output/{random_string}.png')
response = FileResponse(open('output/'+random_string + '.png', 'rb'))
response['Content-Disposition'] = f'attachment; filename=output/"{random_string}.png"'
os.system(f'rm -rf images_two/{str(request.data["image_two"])} images/{str(request.data["image_one"])} output/{random_string}.png')
return response

# return Response(serializer.errors, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
File renamed without changes

0 comments on commit 3065bce

Please sign in to comment.