Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -8,6 +8,10 @@ import os
|
|
8 |
import uuid
|
9 |
import subprocess
|
10 |
import html
|
|
|
|
|
|
|
|
|
11 |
|
12 |
# Function to download video from a given URL using yt-dlp
|
13 |
def dl(inp):
|
@@ -63,7 +67,10 @@ def process_vid(file, cur_frame, every_n):
|
|
63 |
# Save the current frame as an image file
|
64 |
frame_path = f"{uid}-vid_tmp{i}.png"
|
65 |
cv2.imwrite(frame_path, frame_f)
|
66 |
-
|
|
|
|
|
|
|
67 |
|
68 |
# Perform reverse image search on the extracted frame
|
69 |
res = rev_img_searcher.search(out_url)
|
@@ -98,7 +105,10 @@ def process_im(file, url):
|
|
98 |
read_file.save(f"{uid}-tmp.png")
|
99 |
action_input = f"{uid}-tmp.png"
|
100 |
out = os.path.abspath(action_input)
|
101 |
-
|
|
|
|
|
|
|
102 |
return out_url
|
103 |
|
104 |
# Function to perform reverse image search on a given image
|
@@ -108,9 +118,12 @@ def rev_im(image):
|
|
108 |
|
109 |
# Read the image using OpenCV and save it to a temporary file
|
110 |
image = cv2.imread(image)
|
111 |
-
|
112 |
-
|
113 |
-
|
|
|
|
|
|
|
114 |
|
115 |
# Perform reverse image search
|
116 |
rev_img_searcher = ReverseImageSearcher()
|
|
|
8 |
import uuid
|
9 |
import subprocess
|
10 |
import html
|
11 |
+
import imgbbpy # Adding imgbb to upload images for accessible URLs
|
12 |
+
|
13 |
+
# Initialize imgbb client with your API key (you need to provide your key)
|
14 |
+
imgbb_client = imgbbpy.SyncClient("YOUR_IMGBB_API_KEY")
|
15 |
|
16 |
# Function to download video from a given URL using yt-dlp
|
17 |
def dl(inp):
|
|
|
67 |
# Save the current frame as an image file
|
68 |
frame_path = f"{uid}-vid_tmp{i}.png"
|
69 |
cv2.imwrite(frame_path, frame_f)
|
70 |
+
|
71 |
+
# Upload the frame to imgbb to get a publicly accessible URL
|
72 |
+
response = imgbb_client.upload(file=frame_path)
|
73 |
+
out_url = response.url # Get the public URL from imgbb response
|
74 |
|
75 |
# Perform reverse image search on the extracted frame
|
76 |
res = rev_img_searcher.search(out_url)
|
|
|
105 |
read_file.save(f"{uid}-tmp.png")
|
106 |
action_input = f"{uid}-tmp.png"
|
107 |
out = os.path.abspath(action_input)
|
108 |
+
|
109 |
+
# Upload the image to imgbb to get a publicly accessible URL
|
110 |
+
response = imgbb_client.upload(file=out)
|
111 |
+
out_url = response.url # Get the public URL from imgbb response
|
112 |
return out_url
|
113 |
|
114 |
# Function to perform reverse image search on a given image
|
|
|
118 |
|
119 |
# Read the image using OpenCV and save it to a temporary file
|
120 |
image = cv2.imread(image)
|
121 |
+
tmp_image_path = f"{uid}-im_tmp.png"
|
122 |
+
cv2.imwrite(tmp_image_path, image)
|
123 |
+
|
124 |
+
# Upload the image to imgbb to get a publicly accessible URL
|
125 |
+
response = imgbb_client.upload(file=tmp_image_path)
|
126 |
+
out_url = response.url # Get the public URL from imgbb response
|
127 |
|
128 |
# Perform reverse image search
|
129 |
rev_img_searcher = ReverseImageSearcher()
|