Update app.py
Browse files
app.py
CHANGED
|
@@ -1,53 +1,3 @@
|
|
| 1 |
-
import os
|
| 2 |
-
import zipfile
|
| 3 |
-
|
| 4 |
-
import os
|
| 5 |
-
import zipfile
|
| 6 |
-
|
| 7 |
-
# Define the filename
|
| 8 |
-
zip_filename = 'Images.zip'
|
| 9 |
-
|
| 10 |
-
# Get the current directory path
|
| 11 |
-
current_directory = os.getcwd()
|
| 12 |
-
print(f"Current directory: {current_directory}")
|
| 13 |
-
|
| 14 |
-
# Append a custom string to the current directory path (for demonstration)
|
| 15 |
-
custom_directory = os.path.join(current_directory, 'UnzippedContent')
|
| 16 |
-
|
| 17 |
-
# Ensure the custom directory exists
|
| 18 |
-
os.makedirs(custom_directory, exist_ok=True)
|
| 19 |
-
|
| 20 |
-
# Print the contents of the current directory before unzipping
|
| 21 |
-
print(f"Contents of current directory before unzipping: {os.listdir(current_directory)}")
|
| 22 |
-
|
| 23 |
-
# Check if the zip file exists in the current directory
|
| 24 |
-
zip_file_path = os.path.join(current_directory, zip_filename)
|
| 25 |
-
if os.path.isfile(zip_file_path):
|
| 26 |
-
# Open the zip file
|
| 27 |
-
with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
|
| 28 |
-
# Extract all contents of the zip file to the custom directory
|
| 29 |
-
zip_ref.extractall(custom_directory)
|
| 30 |
-
print(f"'{zip_filename}' has been successfully unzipped to '{custom_directory}'.")
|
| 31 |
-
|
| 32 |
-
# Print the contents of the custom directory after unzipping
|
| 33 |
-
print(f"Contents of '{custom_directory}': {os.listdir(custom_directory)}")
|
| 34 |
-
else:
|
| 35 |
-
print(f"'{zip_filename}' not found in the current directory.")
|
| 36 |
-
|
| 37 |
-
# Print the contents of the current directory after unzipping
|
| 38 |
-
print(f"Contents of current directory after unzipping: {os.listdir(current_directory)}")
|
| 39 |
-
|
| 40 |
-
# Code to list the contents in the application (e.g., web interface)
|
| 41 |
-
def list_unzipped_contents():
|
| 42 |
-
unzipped_contents = os.listdir(custom_directory)
|
| 43 |
-
print(f"Unzipped contents: {unzipped_contents}")
|
| 44 |
-
return unzipped_contents
|
| 45 |
-
|
| 46 |
-
# Call the function to list unzipped contents (this part should be integrated with your app's display logic)
|
| 47 |
-
unzipped_files = list_unzipped_contents()
|
| 48 |
-
# Integrate `unzipped_files` with your app's interface to display the contents
|
| 49 |
-
|
| 50 |
-
|
| 51 |
import gradio as gr
|
| 52 |
import gc
|
| 53 |
import cv2
|
|
@@ -57,15 +7,12 @@ from tqdm import tqdm
|
|
| 57 |
from transformers import DistilBertTokenizer
|
| 58 |
import matplotlib.pyplot as plt
|
| 59 |
from implement import *
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
import os
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
with gr.Blocks(css="style.css") as demo:
|
| 70 |
def get_image_embeddings(valid_df, model_path):
|
| 71 |
tokenizer = DistilBertTokenizer.from_pretrained(CFG.text_tokenizer)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import gc
|
| 3 |
import cv2
|
|
|
|
| 7 |
from transformers import DistilBertTokenizer
|
| 8 |
import matplotlib.pyplot as plt
|
| 9 |
from implement import *
|
| 10 |
+
import config as CFG
|
| 11 |
+
from main import build_loaders
|
| 12 |
+
from CLIP import CLIPModel
|
| 13 |
import os
|
| 14 |
+
os.environ['HTTPS_PROXY']="http://185.46.212.90:80/"
|
| 15 |
+
os.environ['HTTP_PROXY']="http://185.46.212.90:80/"
|
|
|
|
|
|
|
|
|
|
| 16 |
with gr.Blocks(css="style.css") as demo:
|
| 17 |
def get_image_embeddings(valid_df, model_path):
|
| 18 |
tokenizer = DistilBertTokenizer.from_pretrained(CFG.text_tokenizer)
|