### Install GoogleLens via pip Source: https://github.com/aboldev/googlelens/blob/main/README.md Install the GoogleLens library using pip. ```bash pip install GoogleLens ``` -------------------------------- ### Upload image from URL Source: https://github.com/aboldev/googlelens/blob/main/README.md Initialize GoogleLens, upload an image from a URL, and print the visual match results. ```python from googlelens import GoogleLens # Initialize GoogleLens instance lens = GoogleLens() # Upload image from URL url = "https://example.com/sample-image.jpg" result_url = lens.upload_image(url) # Extract and print visual match results print("Results from URL search:") print(result_url.extract_visual_results()) ``` -------------------------------- ### Upload image from file path Source: https://github.com/aboldev/googlelens/blob/main/README.md Initialize GoogleLens, upload an image from a file path, and print the visual match results. ```python from googlelens import GoogleLens # Initialize GoogleLens instance lens = GoogleLens() # Upload image from a file path file_path = "path/to/sample-image.jpg" result_file = lens.upload_image(file_path) # Extract and print visual match results print("Results from file search:") print(result_file.extract_visual_results()) ``` -------------------------------- ### Upload image using bytes Source: https://github.com/aboldev/googlelens/blob/main/README.md Initialize GoogleLens, read an image as bytes, upload it, and print the visual match results. ```python from googlelens import GoogleLens # Initialize GoogleLens instance lens = GoogleLens() # Read image as bytes with open("path/to/sample-image.jpg", "rb") as f: image_bytes = f.read() # Upload image using bytes result_bytes = lens.upload_image(image_bytes) # Extract and print visual match results print("Results from bytes search:") print(result_bytes.extract_visual_results()) ``` -------------------------------- ### GoogleLensResults.extract_visual_results Source: https://github.com/aboldev/googlelens/blob/main/README.md Extracts the visual match results from the Google Lens response, including the main match and a list of similar matches. ```APIDOC ## GoogleLensResults.extract_visual_results ### Description Extracts the visual match results including the main match and a list of similar matches. ### Method extract_visual_results ### Signature `extract_visual_results() -> Dict[str, Union[None, Dict[str, str], List[Dict[str, str]]]]` ### Returns - **Dict[str, Union[None, Dict[str, str], List[Dict[str, str]]]]** - A dictionary containing the main match and similar matches. ### Example ```python result = lens.upload_image("https://example.com/sample-image.jpg") print(result.extract_visual_results()) ``` ``` -------------------------------- ### GoogleLens.upload_image Source: https://github.com/aboldev/googlelens/blob/main/README.md Uploads an image to Google Lens from a URL, file path, or binary data and returns a GoogleLensResults object containing the search results. ```APIDOC ## GoogleLens.upload_image ### Description Uploads an image to Google Lens and returns the search results. Accepts a URL, file path, or binary data. ### Method upload_image ### Signature `upload_image(image_input: Union[str, bytes]) -> GoogleLensResults` ### Parameters - **image_input** (Union[str, bytes]) - Required - Can be a URL (str), file path (str), or binary data (bytes). ### Returns - **GoogleLensResults** - An object containing the parsed search results. ### Example ```python from googlelens import GoogleLens lens = GoogleLens() result = lens.upload_image("https://example.com/sample-image.jpg") ``` ``` -------------------------------- ### Extract raw text from Google Lens results Source: https://github.com/aboldev/googlelens/blob/main/README.md Extract raw text from the Google Lens response using the extract_raw_text method. ```python # Extract raw text from the Google Lens response raw_text = result_url.extract_raw_text() print("Raw text extracted from the response:") print(raw_text) ``` -------------------------------- ### GoogleLensResults.extract_raw_text Source: https://github.com/aboldev/googlelens/blob/main/README.md Extracts raw text from the Google Lens response, if available. ```APIDOC ## GoogleLensResults.extract_raw_text ### Description Extracts raw text from the Google Lens response, if available. ### Method extract_raw_text ### Signature `extract_raw_text() -> List[str]` ### Returns - **List[str]** - A list of raw text strings extracted from the response. ### Example ```python result = lens.upload_image("https://example.com/sample-image.jpg") raw_text = result.extract_raw_text() print(raw_text) ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.