0% found this document useful (0 votes)
3 views5 pages

App Issues

The document outlines troubleshooting steps for a frontend-backend communication issue in a handwriting analysis application, specifically addressing an 'Analysis failed' error. It suggests checking backend logs, testing the API directly, and common issues like model file problems or image processing errors. Additionally, it provides a solution to start the FastAPI backend server and ensure both frontend and backend are running simultaneously for proper communication.

Uploaded by

fahimwazir672
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views5 pages

App Issues

The document outlines troubleshooting steps for a frontend-backend communication issue in a handwriting analysis application, specifically addressing an 'Analysis failed' error. It suggests checking backend logs, testing the API directly, and common issues like model file problems or image processing errors. Additionally, it provides a solution to start the FastAPI backend server and ensure both frontend and backend are running simultaneously for proper communication.

Uploaded by

fahimwazir672
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Problem 1

Great! The frontend is working and communicating with the backend, but there's an error in
the analysis process. The message "Analysis failed. Please try again with a clearer handwriting
sample." suggests the backend is returning an error.

Let's troubleshoot this step by step:

1. First, check the backend logs

Look at the terminal where your FastAPI server is running. You should see error messages
there that explain what went wrong.

2. Test the backend API directly

Open a new PowerShell window and test the API with curl:

powershell

# Download a test image first


curl -o test_image.jpg [Link]
# Test the API endpoint
curl -X POST "[Link] -F "file=@test_image.jpg"

3. Common issues that could cause this:

Issue 1: Model file not found or corrupted

•Check if personality_model_final.pth exists in the backend folder


•Verify the file size is reasonable (not 0 bytes)

Issue 2: EasyOCR unable to detect text

•The handwriting sample might not have enough detectable text


•Try with a clearer, larger handwriting sample

Issue 3: Image processing issues

•The image might be in an unsupported format


•Try with a different image format (JPEG, PNG)

Issue 4: Memory issues

•The model might be too large for your system memory

4. Check the browser developer tools

[Link] [Link]
[Link] F12 → Network tab
[Link] an image and click "Analyze"
[Link] at the response from the /analyze API call

5. Try with a different handwriting sample

Use a clear, high-contrast handwriting sample with several lines of text.


6. Check the backend code for error handling

In your [Link], look at the /analyze endpoint - it might be throwing an exception that's being
caught and returning the error message.

7. Test with a simple image

Create a simple image with clear text using Paint or any image editor:

•White background
•Black text
•Several lines of handwriting-like text

The fact that you're seeing the "Analyzing..." message means the frontend is working correctly
and sending requests to the backend. The issue is in the backend processing. Check the
backend terminal for specific error messages - that will give us the exact cause of the
problem.

Problem 1
Perfect! Now I can see the exact error. The frontend is trying to connect to the backend
at [Link] but getting a connection refused error. This means your
backend server is not running or not accessible.

Solution: Start Your Backend Server

You need to start the FastAPI backend server in a separate terminal:

Step 1: Open a new PowerShell window

Step 2: Navigate to your backend folder


powershell

cd F:\handwriting-personality-app\backend

Step 3: Activate the virtual environment


powershell

.\venv\Scripts\activate

Step 4: Start the FastAPI server


powershell

uvicorn api:app --reload --host [Link] --port 8000

You should see output like:

text

INFO: Uvicorn running on [Link] (Press CTRL+C to quit)


INFO: Started reloader process [XXXXX] using StatReload
INFO: Started server process [XXXXX]
INFO: Waiting for application startup.
Using CPU. Note: This module is much faster with a GPU.
Models loaded successfully!
INFO: Application startup complete.

Step 5: Verify backend is working

Open [Link] in your browser - you should see the API welcome message.

Step 6: Now try your frontend again

Refresh [Link] and try uploading an image again.

Why this happened:


•Frontend (React) runs on port 3000
•Backend (FastAPI) runs on port 8000
•The frontend tries to send requests to port 8000
•If the backend isn't running, you get "connection refused"

To run both together:

Terminal 1 - Backend:

powershell

cd backend
.\venv\Scripts\activate
uvicorn api:app --reload --host [Link] --port 8000

Terminal 2 - Frontend:

powershell

cd frontend
npm run dev

Now both servers will be running and able to communicate with each other! 🚀

You might also like