Created
September 9, 2023 11:25
-
-
Save KaushikShresth07/aa60caba82fe18f2c2d53077e2dfb641 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Text Modification Function - | |
| def split_and_save_paragraphs(data, filename): | |
| paragraphs = data.split('\n\n') | |
| with open(filename, 'w') as file: | |
| file.write(data) | |
| data = paragraphs[:2] | |
| separator = ', ' | |
| joined_string = separator.join(data) | |
| return joined_string | |
| # Main Execution | |
| while True: | |
| Question = input("Enter The Query : ") | |
| RealQuestion = str(Question) | |
| results = bard.get_answer(RealQuestion)['content'] | |
| current_datetime = datetime.datetime.now() | |
| formatted_time = current_datetime.strftime("%H%M%S") | |
| filenamedate = str(formatted_time) + str(".txt") | |
| filenamedate = "DataBase//" + filenamedate | |
| print(split_and_save_paragraphs(results, filename=filenamedate)) | |
| # Image Detection | |
| while True: | |
| imagename = str(input("Enter The Image Name : ")) | |
| image = open(imagename,'rb').read() | |
| bard = BardCookies(cookie_dict=cookie_dict) | |
| results = bard.ask_about_image('what is in the image?',image=image)['content'] | |
| current_datetime = datetime.datetime.now() | |
| formatted_time = current_datetime.strftime("%H%M%S") | |
| filenamedate = str(formatted_time) + str(".txt") | |
| filenamedate = "DataBase//" + filenamedate | |
| print(split_and_save_paragraphs(results, filename=filenamedate)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$ "c:/Users/Mahadiul Hasan/Desktop/jarvis/venv/Scripts/python.exe" "c:/Users/Mahadiul Hasan/Desktop/jarvis/Features/ImageDetection.py"
Enter The Image Name : C:\Users\Mahadiul Hasan\Downloads\carousel.jpg
Traceback (most recent call last):
File "c:\Users\Mahadiul Hasan\Desktop\jarvis\Features\ImageDetection.py", line 82, in
results = bard.ask_about_image('what is in the image?',image=image)['content']
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Mahadiul Hasan\Desktop\jarvis\venv\Lib\site-packages\bardapi\core_cookies.py", line 211, in ask_about_image
return super().ask_about_image(input_text, image, lang)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Mahadiul Hasan\Desktop\jarvis\venv\Lib\site-packages\bardapi\core.py", line 674, in ask_about_image
translator_to_eng = GoogleTranslator(source="auto", target="en")
^^^^^^^^^^^^^^^^
NameError: name 'GoogleTranslator' is not defined
This error given in image ditection