Spaces:
Running
Running
Create utils.py
Browse files
utils.py
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
|
3 |
+
def create_output_directory(directory="output"):
|
4 |
+
"""Create output directory if it doesn't exist"""
|
5 |
+
if not os.path.exists(directory):
|
6 |
+
os.makedirs(directory)
|
7 |
+
return directory
|
8 |
+
|
9 |
+
def allowed_file(filename):
|
10 |
+
"""Check if file has allowed extension"""
|
11 |
+
ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg'}
|
12 |
+
return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
|
13 |
+
|