How phuongtna1/gsu25ai07-deblur-app works
Project type and purpose
• This is a monolithic, full-stack Python web application built on Streamlit.
• Purpose: allow users to upload a blurred image, pick one of six deep-learning or diffusion models, tune sampling parameters, and get an interactive deblurred result.
Main components
a. Streamlit UI (app.py)
• Handles file upload, cropping/resizing, parameter sliders, model selection, display & download.
b. Preprocessing & Postprocessing (utils.py)
• Image I/O (PIL/OpenCV), cropping, resizing, brightness/hue adjustments, slider comparison widget.
c. Model definitions
• standalone_model.py: CNN, UNet, ResNet architectures
• diff_model.py: Diffusion (DDPM/DDIM) variants of those architectures
d. Inference orchestration (utils.py)
• Loads the selected model, fetches weights, runs forward pass, returns output tensor → PIL image
e. Model weights storage
• a models.zip stored on Google Drive; auto-download & extract on first run, then cached locally
f. External services & dependencies
• Google Drive (for weights)
• PyTorch, Streamlit, image-processing libs defined in requirements.txt
Relationships & data flow
1. User uploads image → Streamlit UI
2. UI → Preprocessor (utils)
3. Preprocessor outputs tensor → Inference orchestrator
4. Orchestrator calls Model Loader → downloads/extracts weights if missing
5. Orchestrator instantiates correct model class (from standalone_model or diff_model) → runs inference
6. Raw output tensor → Postprocessor (utils) → PIL image
7. Streamlit UI displays before/after slider, zoom & brightness controls
8. User triggers “Download” → UI streams file to browser
Architectural patterns & design principles
• Monolithic MVC-style separation:
• View = Streamlit components in app.py
• Controller = utils.py orchestrating I/O & inference
• Model layer = standalone_model.py + diff_model.py
• Lazy loading / caching of large assets (models.zip)
• Single process, request-driven pipeline (no microservices)