It looks like you're using an Ad Blocker.

Please white-list or disable AboveTopSecret.com in your ad-blocking tool.

Thank you.

 

Some features of ATS will be disabled while you continue to use an ad-blocker.

 

UFO / IFO images : Coding challenge - batch reverse image searches (Python / Selenium?)

page: 2
19
<< 1   >>

log in

join
share:

posted on Mar, 28 2022 @ 12:08 PM
link   
a reply to: Pretzelcoatl

I agree with you. But you know with programming languages it happens the exact same thing that with natural languages: native speakers always believe their mother tongue is the best of them all, the more expressive, and so on.

In my view, almost everything can be done with any programming language, Brain# included, given time and resources enough. The situation changes when you are required to do it in just one language, without calling foreing routines or libraries, and it dramatically changes when there is a budget and a timeline to meet. Due to my background I do belong to the Algol68-Fortran-Lisp-Ada universe and rarely use any other programming language, except for IDL and J when it comes to astrophysics numeric applications.

I guess your remark on popularity has to do with the specific programming niche. Python, I feel, is okay for generic tasks and the one IsaacKoi is looking after is such a task. Quite a different thing would be if he wishes to perform complex image processing efficiently and quickly. And quite different if, besides that, the customer is a defense contractor, in which case only two languages would do the job.



posted on Mar, 28 2022 @ 05:07 PM
link   
a reply to: Direne

Yes, after many years developing in large teams of varying skill levels, I have a natural tendency towards accessibility. While I enjoy learning new languages, I've worked with a lot of bored people who just aren't interested.

I'm in the video games industry which isn't quite as cool as secret astrophysics defense contracts, but it can be pretty neat sometimes.



posted on Apr, 9 2023 @ 12:36 PM
link   
ChatGPT3.5 has been helping me with some code for this mini-project.

In fact, I outlined the project and it generated a first draft of all the code. That code didn't quite work, but ChatGPT has also helped with some debugging. The code now runs - up to a point. I think one element is slightly out of date (the XPATH id for the "search by image" button on the Google Image Search website).

Here's the current version of the relevant Python code:


import os
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

# Set up the webdriver for Google Chrome
driver = webdriver.Chrome()

# Define the path to the folder containing the photographs to be searched
folder_path = 'E:\temp\reverse'

# Loop through each file in the specified folder
for filename in os.listdir(folder_path):
# Skip non-image files
if not filename.endswith(('.jpg', '.jpeg', '.png')):
continue

# Load the Google Images page and enter the image URL
driver.get('https://images.google.com/')
try:
# Wait until the "I agree" button is clickable
agree_button = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "L2AGLb")))
agree_button.)
time.sleep(3)

# Click on the "Search by image" button
search_image_button = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//a[@class='H6eFf']")))
search_image_button.)
time.sleep(3)

# Click on the "Upload an image" option
upload_image_option = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="qbba"]/span[2]')))
upload_image_option.)
time.sleep(3)

# Find the search box element on the webpage
search_box = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, '//*[@id="qbfile"]')))
image_path = os.path.join(folder_path, filename)
search_box.send_keys(image_path)
time.sleep(3)

# Click on the "Search" button
search_button = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="qbbtc"]/span[2]')))
search_button.)
time.sleep(3)

# Wait for the search results to load
search_results = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, 'islrg')))
time.sleep(3)

# Take a screenshot of the search results and save it with the same filename as the photo but with a suffix
name, ext = os.path.splitext(filename)
screenshot_name = name + '_search results.jpeg'
driver.save_screenshot(os.path.join(folder_path, screenshot_name))
except:
print(f"Failed to search for image [filename]")

# Clean up the webdriver
driver.quit()



posted on Apr, 9 2023 @ 03:01 PM
link   
a reply to: IsaacKoi

Bookmarked.



ETA: this may help: StackOverflow


edit on 4/9/2023 by MykeNukem because: eh?




top topics
 
19
<< 1   >>

log in

join