Spaces:
Build error
Build error
阿灰 commited on
Commit ·
a8dcb7f
1
Parent(s): 5022a2d
update oss bucket
Browse files6 unmodified lines78910111210 unmodified lines2324252627282930313233346 unmodified lines414243444546476 unmodified linesfrom datetime import datetimeimport oss2import cv2from pathlib import Pathimport decordfrom gradio.utils import get_cache_folder10 unmodified linesself.create()def upload_to_oss(local_file_path, remote_file_path, expire_time=3600):remote_url = "motionshop/%s/%s" %(datetime.now().strftime("%Y%m%d"), remote_file_path)for i in range(5):try:from oss2.credentials import EnvironmentVariableCredentialsProviderauth = oss2.ProviderAuth(EnvironmentVariableCredentialsProvider())bucket = oss2.Bucket(auth, 'oss-cn-hangzhou.aliyuncs.com', 'virtualbuy-devo')bucket.put_object_from_file(key=remote_url, filename=local_file_path)breakexcept Exception as e:6 unmodified linesdef get_url(filepath):filename = os.path.basename(filepath)remote_file_path = "test/%s" %filenamereturn upload_to_oss(filepath, remote_file_path)def online_detect(filepath):6 unmodified lines7891011121310 unmodified lines2425262728293031323334356 unmodified lines424344454647486 unmodified linesfrom datetime import datetimeimport oss2import cv2import uuidfrom pathlib import Pathimport decordfrom gradio.utils import get_cache_folder10 unmodified linesself.create()def upload_to_oss(local_file_path, remote_file_path, expire_time=3600):remote_url = "motionshop2/%s/%s" %(datetime.now().strftime("%Y%m%d"), remote_file_path)for i in range(5):try:from oss2.credentials import EnvironmentVariableCredentialsProviderauth = oss2.ProviderAuth(EnvironmentVariableCredentialsProvider())bucket = oss2.Bucket(auth, 'oss-us-east-1.aliyuncs.com', 'huggingface-motionshop')bucket.put_object_from_file(key=remote_url, filename=local_file_path)breakexcept Exception as e:6 unmodified linesdef get_url(filepath):filename = os.path.basename(filepath)remote_file_path = "%s_%s" %(uuid.uuid4(), filename)return upload_to_oss(filepath, remote_file_path)def online_detect(filepath):
app.py+4-3