rmayormartins
commited on
Commit
·
230d5dd
1
Parent(s):
a97deb9
Subindo arquivos2
Browse files
app.py
CHANGED
@@ -3,11 +3,6 @@ import os
|
|
3 |
import glob
|
4 |
import exifread
|
5 |
from iptcinfo3 import IPTCInfo
|
6 |
-
from google.colab import drive
|
7 |
-
|
8 |
-
# Function to mount Google Drive (for testing purposes)
|
9 |
-
def mount_drive():
|
10 |
-
drive.mount('/content/drive')
|
11 |
|
12 |
# Extract EXIF metadata
|
13 |
def extract_exif_metadata(filename):
|
@@ -77,7 +72,7 @@ def check_license(exif_data, iptc_data):
|
|
77 |
return license_type
|
78 |
|
79 |
# Main function to process uploaded images
|
80 |
-
def process_images(files=None, url=None
|
81 |
results = []
|
82 |
license_summary = {
|
83 |
'No License Found': 0,
|
@@ -119,25 +114,6 @@ def process_images(files=None, url=None, drive_path=None):
|
|
119 |
if url:
|
120 |
results.append("URL analysis not implemented yet")
|
121 |
|
122 |
-
if drive_path:
|
123 |
-
for filename in glob.iglob(drive_path + '/*', recursive=True):
|
124 |
-
if filename.lower().endswith(('.jpg', '.jpeg', '.png', '.gif', '.bmp', '.tiff')):
|
125 |
-
exif_data = extract_exif_metadata(filename)
|
126 |
-
iptc_data = extract_iptc_metadata(filename)
|
127 |
-
license_type = check_license(exif_data, iptc_data)
|
128 |
-
|
129 |
-
if not license_type:
|
130 |
-
possible_license = alternative_license_search(exif_data, iptc_data)
|
131 |
-
if possible_license:
|
132 |
-
license_type = 'Possible License Found (Alternative)'
|
133 |
-
|
134 |
-
if license_type:
|
135 |
-
license_summary[license_type] += 1
|
136 |
-
else:
|
137 |
-
license_summary['No License Found'] += 1
|
138 |
-
|
139 |
-
results.append(f"File: {filename} - License: {license_type if license_type else 'No License Found'}")
|
140 |
-
|
141 |
summary = "\nLicense Summary:\n"
|
142 |
for license_type, count in license_summary.items():
|
143 |
summary += f"{license_type}: {count} images\n"
|
@@ -154,13 +130,10 @@ with gr.Blocks() as interface:
|
|
154 |
with gr.Column():
|
155 |
files = gr.File(file_count="multiple", label="Upload Images")
|
156 |
url = gr.Textbox(label="Or provide an image URL")
|
157 |
-
drive_path = gr.Textbox(label="Or provide a Google Drive folder path (e.g., /content/drive/MyDrive/yourfolder)")
|
158 |
|
159 |
output = gr.Textbox(label="Results")
|
160 |
|
161 |
submit_button = gr.Button("Inspect")
|
162 |
-
submit_button.click(process_images, inputs=[files, url
|
163 |
-
|
164 |
-
mount_drive()
|
165 |
|
166 |
interface.launch()
|
|
|
3 |
import glob
|
4 |
import exifread
|
5 |
from iptcinfo3 import IPTCInfo
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
# Extract EXIF metadata
|
8 |
def extract_exif_metadata(filename):
|
|
|
72 |
return license_type
|
73 |
|
74 |
# Main function to process uploaded images
|
75 |
+
def process_images(files=None, url=None):
|
76 |
results = []
|
77 |
license_summary = {
|
78 |
'No License Found': 0,
|
|
|
114 |
if url:
|
115 |
results.append("URL analysis not implemented yet")
|
116 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
summary = "\nLicense Summary:\n"
|
118 |
for license_type, count in license_summary.items():
|
119 |
summary += f"{license_type}: {count} images\n"
|
|
|
130 |
with gr.Column():
|
131 |
files = gr.File(file_count="multiple", label="Upload Images")
|
132 |
url = gr.Textbox(label="Or provide an image URL")
|
|
|
133 |
|
134 |
output = gr.Textbox(label="Results")
|
135 |
|
136 |
submit_button = gr.Button("Inspect")
|
137 |
+
submit_button.click(process_images, inputs=[files, url], outputs=output)
|
|
|
|
|
138 |
|
139 |
interface.launch()
|