aryrk commited on
Commit
95f6ecc
·
1 Parent(s): 47a1b1e

[feat] add Auto Aspect Ratio

Browse files
Files changed (1) hide show
  1. app.py +12 -1
app.py CHANGED
@@ -42,6 +42,16 @@ def reflection_removal(input_image):
42
 
43
  input_filename = os.path.splitext(os.path.basename(file_path))[0]
44
 
 
 
 
 
 
 
 
 
 
 
45
  cmd = [
46
  "python", "test.py",
47
  "--dataroot", UPLOAD_DIR,
@@ -50,7 +60,8 @@ def reflection_removal(input_image):
50
  "--direction", "AtoB", "--dataset_mode", "single",
51
  "--norm", "batch", "--epoch", "310",
52
  "--num_test", str(count_files(UPLOAD_DIR)),
53
- "--gpu_ids", "-1"
 
54
  ]
55
  subprocess.run(cmd, check=True)
56
 
 
42
 
43
  input_filename = os.path.splitext(os.path.basename(file_path))[0]
44
 
45
+ aspect_ratio = 1.0
46
+
47
+ try:
48
+ with Image.open(file_path) as img:
49
+ width, height = img.size
50
+ aspect_ratio = width / height
51
+ print(f"Aspect Ratio: {aspect_ratio}")
52
+ except Exception as e:
53
+ pass
54
+
55
  cmd = [
56
  "python", "test.py",
57
  "--dataroot", UPLOAD_DIR,
 
60
  "--direction", "AtoB", "--dataset_mode", "single",
61
  "--norm", "batch", "--epoch", "310",
62
  "--num_test", str(count_files(UPLOAD_DIR)),
63
+ "--gpu_ids", "-1",
64
+ "--aspect_ratio", str(aspect_ratio)
65
  ]
66
  subprocess.run(cmd, check=True)
67