File size: 764 Bytes
cabbe93
daa1246
 
cabbe93
 
daa1246
cabbe93
daa1246
cabbe93
 
 
 
 
 
9ebca05
 
 
cabbe93
 
 
 
 
 
 
 
daa1246
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import os
import gradio as gr
from image_similarity import ImageSimilarity
from services.aws_service import AwsService
from dotenv import load_dotenv

load_dotenv()

def check_image_similarity(photo_shoot_id):
  folder = "PhotoShoots/" + str(photo_shoot_id) + "/Inputs"
  files = AwsService.get_files_from_s3(os.environ.get('AWS_S3_BUCKET'), folder)

  images = []
  for file in files:
    params = file['Key'].split('/')
    if params[-1] != '' and params[-1] != ' ':
        images.append(AwsService.get_image_from_s3(os.environ.get('AWS_S3_BUCKET'), file['Key']))
    
  return ImageSimilarity(1).check(images)

iface = gr.Interface(
  fn=check_image_similarity, 
  inputs=[gr.Textbox(lines=1, placeholder="Photo Shoot ID")], 
  outputs="text"
)

iface.launch()