This repository contains the efficient inference part of the CSC_5IA21 project: https://giannifranchi.github.io/CSC_5IA21.html
The code benchmarks FLUX.2 variants under constrained hardware, with emphasis on quantization, offloading, monitoring, and OCR-aware quality evaluation.

Benchmarked model family:
Benchmarked execution strategies:
efficient_image_generation/
src/
models/ # model descriptors/loaders
offload/ # smart offloading + pipeline patches
monitoring/ # runtime monitor + metrics aggregation
evaluation/ # OCR, SSIM, FID, CLIP modules
benchmark_offload.py # hardware/offloading benchmark orchestration
benchmark_models.py # prompt/seed/model image generation benchmark
comfy_benchmark.py # ComfyUI low-VRAM benchmark path
evaluate_ocr.py # OCR evaluation pipeline
evaluate_ssim_clip_fid.py # SSIM/FID/CLIP evaluation pipeline
report_figures.py # report figure generation
figures/ # benchmark and qualitative figures
results/ # generated images and CSV outputs
Main orchestration: benchmark_offload.py
Example:
python benchmark_offload.py
Main source: src/offload/offload.py
SmartOffloadManager classifies modules into resident vs streaming according to VRAM budget.Minimal usage pattern:
from src.offload.offload import SmartOffloadManager
mgr = SmartOffloadManager(transformer, max_vram_gb=6.0, device="cuda", num_streams=2)
mgr.load()
# run inference
mgr.unload()
Main sources:
src/monitoring/resource_monitor.pysrc/monitoring/metrics.pySampling backend combines:
psutil for process CPU/RAM,pynvml for GPU utilization/power/PCIe,Minimal usage pattern:
from src.monitoring import ResourceMonitor
with ResourceMonitor(sample_rate_hz=5.0) as mon:
# run generation
pass
metrics = mon.get_metrics()
df = metrics.to_dataframe()
print(metrics.vram_reserved_max_mb, metrics.ram_max_mb)
Main sources:
src/evaluation/ocr.py and evaluate_ocr.pysrc/evaluation/ssim.pysrc/evaluation/fid.pysrc/evaluation/clip_score.pyevaluate_ssim_clip_fid.pyOCR backends in code:
zai-org/GLM-OCR).Example OCR run:
python evaluate_ocr.py
Example SSIM/FID/CLIP run:
python evaluate_ssim_clip_fid.py




9 commits
Python
99.5%
This repository contains the efficient inference part of the CSC_5IA21 project: https://giannifranchi.github.io/CSC_5IA21.html
The code benchmarks FLUX.2 variants under constrained hardware, with emphasis on quantization, offloading, monitoring, and OCR-aware quality evaluation.

Benchmarked model family:
Benchmarked execution strategies:
efficient_image_generation/
src/
models/ # model descriptors/loaders
offload/ # smart offloading + pipeline patches
monitoring/ # runtime monitor + metrics aggregation
evaluation/ # OCR, SSIM, FID, CLIP modules
benchmark_offload.py # hardware/offloading benchmark orchestration
benchmark_models.py # prompt/seed/model image generation benchmark
comfy_benchmark.py # ComfyUI low-VRAM benchmark path
evaluate_ocr.py # OCR evaluation pipeline
evaluate_ssim_clip_fid.py # SSIM/FID/CLIP evaluation pipeline
report_figures.py # report figure generation
figures/ # benchmark and qualitative figures
results/ # generated images and CSV outputs
Main orchestration: benchmark_offload.py
Example:
python benchmark_offload.py
Main source: src/offload/offload.py
SmartOffloadManager classifies modules into resident vs streaming according to VRAM budget.Minimal usage pattern:
from src.offload.offload import SmartOffloadManager
mgr = SmartOffloadManager(transformer, max_vram_gb=6.0, device="cuda", num_streams=2)
mgr.load()
# run inference
mgr.unload()
Main sources:
src/monitoring/resource_monitor.pysrc/monitoring/metrics.pySampling backend combines:
psutil for process CPU/RAM,pynvml for GPU utilization/power/PCIe,Minimal usage pattern:
from src.monitoring import ResourceMonitor
with ResourceMonitor(sample_rate_hz=5.0) as mon:
# run generation
pass
metrics = mon.get_metrics()
df = metrics.to_dataframe()
print(metrics.vram_reserved_max_mb, metrics.ram_max_mb)
Main sources:
src/evaluation/ocr.py and evaluate_ocr.pysrc/evaluation/ssim.pysrc/evaluation/fid.pysrc/evaluation/clip_score.pyevaluate_ssim_clip_fid.pyOCR backends in code:
zai-org/GLM-OCR).Example OCR run:
python evaluate_ocr.py
Example SSIM/FID/CLIP run:
python evaluate_ssim_clip_fid.py




9 commits
Python
99.5%