-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Claude/streamlit image upload app 011 c ud9cb a5 hdzs y3 mge xpq m #192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
cadusp
wants to merge
7
commits into
deepseek-ai:main
Choose a base branch
from
cadusp:claude/streamlit-image-upload-app-011CUd9cbA5HdzsY3MgeXpqM
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Claude/streamlit image upload app 011 c ud9cb a5 hdzs y3 mge xpq m #192
cadusp
wants to merge
7
commits into
deepseek-ai:main
from
cadusp:claude/streamlit-image-upload-app-011CUd9cbA5HdzsY3MgeXpqM
Conversation
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
- Created streamlit_ocr_app.py: Complete web application for image OCR - Features: * Image upload support (JPG, PNG, JPEG) * Multiple resolution modes (Tiny, Small, Base, Large, Gundam, Custom) * Predefined prompts for different OCR tasks * Real-time OCR processing with DeepSeek model * Result visualization (text, markdown, statistics) * Download results as TXT or MD files * Advanced settings (test_compress, save_results) * Full transforms integration (ImageTransform, dynamic_preprocess, count_tiles) - Added requirements_streamlit.txt: Dependencies for Streamlit app - Added STREAMLIT_README.md: Complete documentation with usage examples All functionality integrated in a single file as requested. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Fixes: - Replace use_container_width with width='stretch' (Streamlit 2025-12-31 deprecation) * st.image: use_container_width=True -> width='stretch' * st.button: use_container_width=True -> width='stretch' - Add automatic fallback for flash_attn not installed * Try to load with flash_attention_2 first (best performance) * Fallback to eager attention if flash_attn not available * Show informative messages during model loading * Works on both GPU and CPU without flash_attn Updates: - requirements_streamlit.txt: Add comments about optional flash-attn - STREAMLIT_README.md: * Add section about Flash Attention 2 installation * Add troubleshooting for flash_attn errors * Clarify that app works without flash_attn * Explain deepseek_vl_v2 warning is not critical The application now works out of the box without flash-attn installed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Changes: - Force device to CPU regardless of CUDA availability - Remove GPU/CUDA detection and configuration - Use torch.float32 instead of torch.bfloat16 for CPU compatibility - Simplify model loading (no flash_attention_2 needed on CPU) - Update sidebar to show CPU-only configuration - Add warning that processing will be slower but functional This configuration ensures the app runs on CPU-only environments without requiring CUDA or GPU hardware. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Fixes the warning: "You are using a model of type deepseek_vl_v2 to instantiate a model of type DeepseekOCR. This is not supported for all configurations of models and can yield errors." Changes to streamlit_ocr_app.py: - Add warnings module import - Filter warnings for deepseek_vl_v2 and DeepseekOCR type mismatch - Set TRANSFORMERS_VERBOSITY to 'error' to suppress non-critical warnings - Add new expander section "⚠️ Notas Técnicas e Avisos Conhecidos" with: * Detailed explanation of the warning * Why it happens (config.json vs Python class naming) * Why it's safe to ignore (trust_remote_code=True behavior) * CPU vs GPU configuration notes * Flash Attention 2 optional dependency info Changes to STREAMLIT_README.md: - Expand section about deepseek_vl_v2 warning - Add detailed explanation of why the warning appears - Clarify that it's informational only and not an error - Explain trust_remote_code=True behavior - Note that app automatically suppresses this warning The warning is expected and harmless when using trust_remote_code=True with custom model architectures. The model loads and functions perfectly. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Fixes SafetensorError: "EOF while parsing a value" error that occurs when HuggingFace cache has corrupted/incomplete model files. Changes to streamlit_ocr_app.py: - Add clear_model_cache() helper function to remove corrupted cache - Enhanced load_model() with multi-stage error recovery: 1. Try loading with safetensors (normal) 2. If SafetensorError detected, identify corrupted files 3. Automatically clear cache and re-download model 4. Fallback to loading without safetensors if needed - Add comprehensive error messages with manual recovery instructions - Show step-by-step instructions for Windows/Linux/Mac - Include PowerShell commands for Windows cache cleanup - Add environment variable workarounds (TRANSFORMERS_CACHE, HF_HUB_DISABLE_SYMLINKS) Changes to STREAMLIT_README.md: - Add dedicated section for SafetensorError troubleshooting - Explain causes: interrupted download, connection issues, corrupted cache - Document automatic recovery process (4 steps) - Provide manual recovery instructions for all platforms - Add prevention tips: stable connection, sufficient disk space - Include cache location paths for Windows/Linux/Mac Error detection patterns: - "SafetensorError" in error message - "EOF while parsing" in error message - "invalid JSON" in error message Recovery flow: 1. Detect SafetensorError → Warn user 2. Find cache dirs matching "*deepseek*" → Remove all 3. Force re-download with force_download=True 4. If fails → Fallback to use_safetensors=False This ensures the app can recover from corrupted downloads automatically without requiring manual intervention in most cases. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Fixed error that occurred when trying to display processing configuration. The variable 'device_info' was removed when we forced CPU usage but was still being referenced in the config_info dictionary on line 419. Change: - Line 419: "Device": device_info → "Device": "CPU (Forçado)" This hardcoded value is correct since the app is configured to always use CPU (device = "cpu" on line 101). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Added comprehensive .gitignore to exclude: - Python cache files (__pycache__/, *.pyc, *.pyo) - Virtual environments (venv/, env/) - IDE files (.vscode/, .idea/) - OS files (.DS_Store, Thumbs.db) - Build artifacts (dist/, build/, *.egg-info/) - Jupyter checkpoints - Streamlit cache This prevents committing auto-generated files that should not be in version control. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.