This application allows you to upload an image and ask questions about it. The chatbot uses Visual Question Answering VQA models to provide relevant answers.
- Model Selection: Choose between different VQA models (currently supports BLIP).
- Image Upload: Upload an image in JPG, PNG, or JPEG format.
- Interactive Chat: Ask questions about the uploaded image and receive responses.
- Upload an Image: Use the sidebar to upload an image. The image will be displayed in the sidebar.
- Ask Questions: Type your question in the chat input box at the bottom of the page.
- Get Responses: The selected VQA model processes the question and image to generate an answer, which is displayed in the chat.
Follow these instructions to create a virtual environment for a specified version of Python.
- Ensure Python is installed on your system. You can download it from python.org.
- Verify that
pipis installed by runningpip --versionin your terminal or command prompt.
If not already installed, you need to install virtualenv using pip:
pip install virtualenvCreate a virtual environment specifying the path to the Python interpreter for the version you wish to use. Replace path/to/python with the actual path and myenv with your desired environment name:
virtualenv -p /path/to/python myenv-
Example for Windows: If Python 3.8 is installed at
C:\Python38\python.exe:virtualenv -p C:\Python38\python.exe myenv
-
Example for macOS/Linux: If Python 3.8 is installed and the executable is named
python3.8:virtualenv -p python3.8 myenv
Activate the newly created virtual environment:
-
On Windows:
myenv\Scripts\activate
-
On macOS/Linux:
source myenv/bin/activate
Check the Python version to ensure the correct version is activated:
python --versionTo stop using the virtual environment and revert to the default Python settings:
deactivateThis completes the setup of a Python virtual environment with your specified version.
Activate the virtual environment and install the required packages using the following command:
pip install -r requirements.txtRun the application with the following commands:
cd chatbot
streamlit run app.py- Open the Application: Once the Streamlit app is running, open your browser and navigate to the local server URL provided.
- Upload an Image: Use the sidebar to upload an image file. The uploaded image will be displayed in the sidebar.
- Ask a Question: Type your question in the chat input box at the bottom of the page.
- Receive an Answer: The chatbot will process your question and the uploaded image, and provide an answer in the chat interface.
-
The application downloads the Hugging Face models and caches them inside the
modelsfolder when you run the application for the first time. Therefore, the first run will be slower. In subsequent runs, it will load the downloaded models stored locally. -
If you encounter errors related to the Hugging Face transformers library, you can install the latest version directly using the following command:
pip install git+https://github.com/huggingface/transformers