TheLastBen commited on
Commit
dfd56af
1 Parent(s): fb3fac6

Update Scripts/mainpaperspacev2.py

Browse files
Files changed (1) hide show
  1. Scripts/mainpaperspacev2.py +10 -7
Scripts/mainpaperspacev2.py CHANGED
@@ -411,14 +411,16 @@ def upld(Remove_existing_instance_images, Crop_images, Crop_size, IMAGES_FOLDER_
411
 
412
  elif IMAGES_FOLDER_OPTIONAL =="":
413
  up=""
414
- for filename, file in uploader.value.items():
 
415
  if filename.split(".")[-1]=="txt":
416
  with open(CAPTIONS_DIR+'/'+filename, 'w') as f:
417
  f.write(file['content'].decode())
418
- up=[(filename, file) for filename, file in uploader.value.items() if filename.split(".")[-1]!="txt"]
419
  if Crop_images:
420
- for filename, file_info in tqdm(up, bar_format=' |{bar:15}| {n_fmt}/{total_fmt} Uploaded'):
421
- img = Image.open(io.BytesIO(file_info['content']))
 
422
  extension = filename.split(".")[-1]
423
  identifier=filename.split(".")[0]
424
 
@@ -440,8 +442,9 @@ def upld(Remove_existing_instance_images, Crop_images, Crop_size, IMAGES_FOLDER_
440
  image[0].save(new_path_with_file, format=extension.upper())
441
 
442
  else:
443
- for filename, file_info in tqdm(uploader.value.items(), bar_format=' |{bar:15}| {n_fmt}/{total_fmt} Uploaded'):
444
- img = Image.open(io.BytesIO(file_info['content']))
 
445
 
446
  extension = filename.split(".")[-1]
447
  identifier=filename.split(".")[0]
@@ -450,7 +453,7 @@ def upld(Remove_existing_instance_images, Crop_images, Crop_size, IMAGES_FOLDER_
450
  img=img.convert("RGB")
451
  img.save(INSTANCE_DIR+"/"+filename, format="JPEG", quality = 100)
452
  else:
453
- img.save(INSTANCE_DIR+"/"+filename, format=extension.upper())
454
 
455
  if ren:
456
  i=0
 
411
 
412
  elif IMAGES_FOLDER_OPTIONAL =="":
413
  up=""
414
+ for file in uploader.value:
415
+ filename = file['name']
416
  if filename.split(".")[-1]=="txt":
417
  with open(CAPTIONS_DIR+'/'+filename, 'w') as f:
418
  f.write(file['content'].decode())
419
+ up=[file for file in uploader.value if filename.split(".")[-1]!="txt"]
420
  if Crop_images:
421
+ for file in tqdm(up, bar_format=' |{bar:15}| {n_fmt}/{total_fmt} Uploaded'):
422
+ filename = file['name']
423
+ img = Image.open(io.BytesIO(file['content']))
424
  extension = filename.split(".")[-1]
425
  identifier=filename.split(".")[0]
426
 
 
442
  image[0].save(new_path_with_file, format=extension.upper())
443
 
444
  else:
445
+ for file in tqdm(uploader.value, bar_format=' |{bar:15}| {n_fmt}/{total_fmt} Uploaded'):
446
+ filename = file['name']
447
+ img = Image.open(io.BytesIO(file['content']))
448
 
449
  extension = filename.split(".")[-1]
450
  identifier=filename.split(".")[0]
 
453
  img=img.convert("RGB")
454
  img.save(INSTANCE_DIR+"/"+filename, format="JPEG", quality = 100)
455
  else:
456
+ img.save(INSTANCE_DIR+"/"+filename, format=extension.upper())
457
 
458
  if ren:
459
  i=0