TheLastBen commited on
Commit
1f8c018
1 Parent(s): db42120

Update Scripts/mainpaperspacev2.py

Browse files
Files changed (1) hide show
  1. Scripts/mainpaperspacev2.py +13 -8
Scripts/mainpaperspacev2.py CHANGED
@@ -323,8 +323,6 @@ def uplder(Remove_existing_instance_images, Crop_images, Crop_size, IMAGES_FOLDE
323
 
324
  if os.path.exists(INSTANCE_DIR+"/.ipynb_checkpoints"):
325
  call('rm -r '+INSTANCE_DIR+'/.ipynb_checkpoints', shell=True)
326
- if os.path.exists(CONCEPT_DIR+"/.ipynb_checkpoints"):
327
- call('rm -r '+CONCEPT_DIR+'/.ipynb_checkpoints', shell=True)
328
 
329
  uploader = widgets.FileUpload(description="Choose images",accept='image/*', multiple=True)
330
  Upload = widgets.Button(
@@ -369,6 +367,10 @@ def upld(Remove_existing_instance_images, Crop_images, Crop_size, IMAGES_FOLDER_
369
 
370
 
371
  if IMAGES_FOLDER_OPTIONAL !="":
 
 
 
 
372
  if any(file.endswith('.{}'.format('txt')) for file in os.listdir(IMAGES_FOLDER_OPTIONAL)):
373
  call('mv '+IMAGES_FOLDER_OPTIONAL+'/*.txt '+CAPTIONS_DIR, shell=True)
374
  if Crop_images:
@@ -384,7 +386,8 @@ def upld(Remove_existing_instance_images, Crop_images, Crop_size, IMAGES_FOLDER_
384
  image = file
385
  if file.size !=(Crop_size, Crop_size):
386
  image=crop_image(file, Crop_size)
387
- if (extension.upper() == "JPG" or "jpg"):
 
388
  image[0].save(new_path_with_file, format="JPEG", quality = 100)
389
  else:
390
  image[0].save(new_path_with_file, format=extension.upper())
@@ -409,7 +412,8 @@ def upld(Remove_existing_instance_images, Crop_images, Crop_size, IMAGES_FOLDER_
409
  extension = filename.split(".")[-1]
410
  identifier=filename.split(".")[0]
411
 
412
- if (extension.upper() == "JPG" or "jpg"):
 
413
  img.save(INSTANCE_DIR+"/"+filename, format="JPEG", quality = 100)
414
  else:
415
  img.save(INSTANCE_DIR+"/"+filename, format=extension.upper())
@@ -420,7 +424,7 @@ def upld(Remove_existing_instance_images, Crop_images, Crop_size, IMAGES_FOLDER_
420
  image = img
421
  if file.size !=(Crop_size, Crop_size):
422
  image=crop_image(file, Crop_size)
423
- if (extension.upper() == "JPG" or "jpg"):
424
  image[0].save(new_path_with_file, format="JPEG", quality = 100)
425
  else:
426
  image[0].save(new_path_with_file, format=extension.upper())
@@ -432,11 +436,11 @@ def upld(Remove_existing_instance_images, Crop_images, Crop_size, IMAGES_FOLDER_
432
  extension = filename.split(".")[-1]
433
  identifier=filename.split(".")[0]
434
 
435
- if (extension.upper() == "JPG" or "jpg"):
 
436
  img.save(INSTANCE_DIR+"/"+filename, format="JPEG", quality = 100)
437
  else:
438
  img.save(INSTANCE_DIR+"/"+filename, format=extension.upper())
439
-
440
 
441
  if ren:
442
  i=0
@@ -478,6 +482,7 @@ def caption(CAPTIONS_DIR, INSTANCE_DIR):
478
  text = f.read()
479
 
480
  img=Image.open(os.path.join(INSTANCE_DIR,path))
 
481
  img=img.resize((420, 420))
482
  image_bytes = BytesIO()
483
  img.save(image_bytes, format=ext, qualiy=10)
@@ -791,7 +796,7 @@ def test(Custom_Path, Previous_Session_Name, Session_Name, User, Password, Use_l
791
  line = ''
792
  sys.stdout.write(line)
793
 
794
- call('rm srv.txt srvr.txt', shell=True))
795
 
796
  os.chdir('/notebooks/sd/stable-diffusion-webui/modules')
797
  call('wget -q -O paths.py https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/AUTOMATIC1111_files/paths.py', shell=True)
 
323
 
324
  if os.path.exists(INSTANCE_DIR+"/.ipynb_checkpoints"):
325
  call('rm -r '+INSTANCE_DIR+'/.ipynb_checkpoints', shell=True)
 
 
326
 
327
  uploader = widgets.FileUpload(description="Choose images",accept='image/*', multiple=True)
328
  Upload = widgets.Button(
 
367
 
368
 
369
  if IMAGES_FOLDER_OPTIONAL !="":
370
+
371
+ if os.path.exists(IMAGES_FOLDER_OPTIONAL+"/.ipynb_checkpoints"):
372
+ call('rm -r '+IMAGES_FOLDER_OPTIONAL+'/.ipynb_checkpoints', shell=True)
373
+
374
  if any(file.endswith('.{}'.format('txt')) for file in os.listdir(IMAGES_FOLDER_OPTIONAL)):
375
  call('mv '+IMAGES_FOLDER_OPTIONAL+'/*.txt '+CAPTIONS_DIR, shell=True)
376
  if Crop_images:
 
386
  image = file
387
  if file.size !=(Crop_size, Crop_size):
388
  image=crop_image(file, Crop_size)
389
+ if extension.upper()=="JPG" or extension.upper()=="jpg":
390
+ image[0] = image[0].convert("RGB")
391
  image[0].save(new_path_with_file, format="JPEG", quality = 100)
392
  else:
393
  image[0].save(new_path_with_file, format=extension.upper())
 
412
  extension = filename.split(".")[-1]
413
  identifier=filename.split(".")[0]
414
 
415
+ if extension.upper()=="JPG" or extension.upper()=="jpg":
416
+ img=img.convert("RGB")
417
  img.save(INSTANCE_DIR+"/"+filename, format="JPEG", quality = 100)
418
  else:
419
  img.save(INSTANCE_DIR+"/"+filename, format=extension.upper())
 
424
  image = img
425
  if file.size !=(Crop_size, Crop_size):
426
  image=crop_image(file, Crop_size)
427
+ if extension.upper()=="JPG" or extension.upper()=="jpg":
428
  image[0].save(new_path_with_file, format="JPEG", quality = 100)
429
  else:
430
  image[0].save(new_path_with_file, format=extension.upper())
 
436
  extension = filename.split(".")[-1]
437
  identifier=filename.split(".")[0]
438
 
439
+ if extension.upper()=="JPG" or extension.upper()=="jpg":
440
+ img=img.convert("RGB")
441
  img.save(INSTANCE_DIR+"/"+filename, format="JPEG", quality = 100)
442
  else:
443
  img.save(INSTANCE_DIR+"/"+filename, format=extension.upper())
 
444
 
445
  if ren:
446
  i=0
 
482
  text = f.read()
483
 
484
  img=Image.open(os.path.join(INSTANCE_DIR,path))
485
+ img=img.convert("RGB")
486
  img=img.resize((420, 420))
487
  image_bytes = BytesIO()
488
  img.save(image_bytes, format=ext, qualiy=10)
 
796
  line = ''
797
  sys.stdout.write(line)
798
 
799
+ call('rm srv.txt srvr.txt', shell=True)
800
 
801
  os.chdir('/notebooks/sd/stable-diffusion-webui/modules')
802
  call('wget -q -O paths.py https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/AUTOMATIC1111_files/paths.py', shell=True)