Update app.py
Browse files10 unmodified lines111213141516171847 unmodified lines6667686970717273747576777879808182838485868787 unmodified lines17517617717817918018118218318414 unmodified lines19920020120220320420520610 unmodified linesimport osimport numpy as npfrom huggingface_hub import hf_hub_download, list_repo_filesimport boto3from botocore.exceptions import NoCredentialsError# Define constantsDESCRIPTION = "[ShowUI Demo](https://huggingface.co/showlab/ShowUI-2B)"47 unmodified linesimg.save(filename)return os.path.abspath(filename)def upload_to_s3(file_name, bucket, object_name=None):"""Upload a file to an S3 bucket."""if object_name is None:object_name = file_names3 = boto3.client('s3')try:s3.upload_file(file_name, bucket, object_name)# print(f"successfully upload {file_name}")return Trueexcept FileNotFoundError:return Falseexcept NoCredentialsError:return Falsedef crop_image(image_path, click_xy, crop_factor=0.5):"""Crop the image around the click point."""image = Image.open(image_path)87 unmodified lineswith open(local_file_name, "w") as f:json.dump(data, f)# Upload JSON and image to S3upload_to_s3(local_file_name, 'altair.storage', object_name=f"ootb/{local_file_name}")upload_to_s3(image_file_name, 'altair.storage', object_name=f"ootb/{image_file_name}")return data14 unmodified lineswith open(local_file_name, "w") as f:json.dump(data, f)upload_to_s3(local_file_name, 'altair.storage', object_name=f"ootb/{local_file_name}")return f"Thank you for your {vote_type}!"10 unmodified lines11121314151647 unmodified lines64656667686987 unmodified lines15715815916016116214 unmodified lines17717817918018118210 unmodified linesimport osimport numpy as npfrom huggingface_hub import hf_hub_download, list_repo_files# Define constantsDESCRIPTION = "[ShowUI Demo](https://huggingface.co/showlab/ShowUI-2B)"47 unmodified linesimg.save(filename)return os.path.abspath(filename)def crop_image(image_path, click_xy, crop_factor=0.5):"""Crop the image around the click point."""image = Image.open(image_path)87 unmodified lineswith open(local_file_name, "w") as f:json.dump(data, f)return data14 unmodified lineswith open(local_file_name, "w") as f:json.dump(data, f)return f"Thank you for your {vote_type}!"
app.py-24