SHREYSH commited on
Commit
0c503a9
1 Parent(s): e5dcff0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -6,11 +6,18 @@ from concurrent.futures import ThreadPoolExecutor
6
 
7
  fawkes_protection = FawkesProtection()
8
 
 
 
 
 
 
9
  def process_images(image_files, protection_level):
10
- images = [Image.open(file) for file in image_files]
11
  with ThreadPoolExecutor() as executor:
12
- futures = [executor.submit(fawkes_protection.predict, img, protection_level) for img in images]
13
- results = [Image.fromarray(future.result()) for future in futures]
 
 
14
  return results
15
 
16
  iface = gr.Interface(
 
6
 
7
  fawkes_protection = FawkesProtection()
8
 
9
+ def process_image(file, protection_level):
10
+ image = Image.open(file)
11
+ protected_image = fawkes_protection.predict(image, protection_level)
12
+ return Image.fromarray(protected_image)
13
+
14
  def process_images(image_files, protection_level):
15
+ results = []
16
  with ThreadPoolExecutor() as executor:
17
+ futures = [executor.submit(process_image, file, protection_level) for file in image_files]
18
+ for future in futures:
19
+ result = future.result()
20
+ results.append(result)
21
  return results
22
 
23
  iface = gr.Interface(