Spaces:
Running
Add a workflow PDF, and stop git rewriting line endings inside binaries
Browse filesdocs/WORKFLOW.pdf documents how the project actually works: architecture, the
submit-and-poll request flow, every pipeline stage with its measured CPU cost,
the deploy path from a push to a running Space, and the behaviour that is easy
to misread from the code (why hair and glasses are opt-in, why quality is scored
before the harmonise stage, CPU vs GPU differences).
It is generated by scripts/make_workflow_pdf.py rather than drawn by hand, so it
can be regenerated when the pipeline changes instead of quietly going stale.
Boxes size themselves from their content β a hand-tuned height had already let
one section overflow its border.
.gitattributes gained binary rules for pdf/png/jpg/onnx/pth. Adding the PDF made
git announce "LF will be replaced by CRLF" for it, which would have corrupted
the file; the existing image assets were unprotected in the same way. Verified
the committed blob is byte-identical to the generated file.
Files changed (3)
- .gitattributes+12
- docs/WORKFLOW.pdfAdded+175
- scripts/make_workflow_pdf.pyAdded+425
12 unmodified lines13141512 unmodified lines*.md text eol=lf*.txt text eol=lfDockerfile text eol=lf12 unmodified lines13141516171819202122232425262712 unmodified lines*.md text eol=lf*.txt text eol=lfDockerfile text eol=lf# Never run line-ending conversion over binaries β it corrupts them. Git was# reporting "LF will be replaced by CRLF" for docs/WORKFLOW.pdf without this.*.pdf binary*.png binary*.jpg binary*.jpeg binary*.webp binary*.bmp binary*.ico binary*.onnx binary*.pth binary
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175%PDF-1.3%οΏ½οΏ½οΏ½οΏ½ ReportLab Generated PDF document (opensource)1 0 obj<</F1 2 0 R /F2 3 0 R /F3 5 0 R>>endobj2 0 obj<</BaseFont /Helvetica /Encoding /WinAnsiEncoding /Name /F1 /Subtype /Type1 /Type /Font>>endobj3 0 obj<</BaseFont /Helvetica-Bold /Encoding /WinAnsiEncoding /Name /F2 /Subtype /Type1 /Type /Font>>endobj4 0 obj<</Contents 14 0 R /MediaBox [ 0 0 595.2756 841.8898 ] /Parent 13 0 R /Resources <</Font 1 0 R /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]>> /Rotate 0 /Trans <<
>> /Type /Page>>endobj5 0 obj<</BaseFont /Helvetica-Oblique /Encoding /WinAnsiEncoding /Name /F3 /Subtype /Type1 /Type /Font>>endobj6 0 obj<</Contents 15 0 R /MediaBox [ 0 0 595.2756 841.8898 ] /Parent 13 0 R /Resources <</Font 1 0 R /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]>> /Rotate 0 /Trans <<
>> /Type /Page>>endobj7 0 obj<</Contents 16 0 R /MediaBox [ 0 0 595.2756 841.8898 ] /Parent 13 0 R /Resources <</Font 1 0 R /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]>> /Rotate 0 /Trans <<
>> /Type /Page>>endobj8 0 obj<</Contents 17 0 R /MediaBox [ 0 0 595.2756 841.8898 ] /Parent 13 0 R /Resources <</Font 1 0 R /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]>> /Rotate 0 /Trans <<
>> /Type /Page>>endobj9 0 obj<</Contents 18 0 R /MediaBox [ 0 0 595.2756 841.8898 ] /Parent 13 0 R /Resources <</Font 1 0 R /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]>> /Rotate 0 /Trans <<
>> /Type /Page>>endobj10 0 obj<</Contents 19 0 R /MediaBox [ 0 0 595.2756 841.8898 ] /Parent 13 0 R /Resources <</Font 1 0 R /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]>> /Rotate 0 /Trans <<
>> /Type /Page>>endobj11 0 obj<</PageMode /UseNone /Pages 13 0 R /Type /Catalog>>endobj12 0 obj<</Author (Aditya Raj) /CreationDate (D:20260907100047+05'00') /Creator (anonymous) /Keywords () /ModDate (D:20260907100047+05'00') /Producer (ReportLab PDF Library - \(opensource\)) /Subject (unspecified) /Title (DeepFace Studio \204 project workflow) /Trapped /False>>endobj13 0 obj<</Count 6 /Kids [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:b(bjLXq6UeeR8Eni`Qo3&1-+H&C34a+KW`q;7;P]?#poaGatH`\oS^#FS0G+>_,UA1!^ubV<Kj@Z22GS6e1XB4`AEaZRY'4iiR&AB#,)idZp2fRqE#K1o&M#FViT9Jr`-9Vo`X1+.Li*\nP"VQqGr4NcC!*.,b&<HO<?433@$AB$9XbTo'-q.ka).hDE[;mo+YJ,f#1YqdIM?<?)U=Vk=4[Cb=KVF6,O3!8e`2<"[3Oeh/ARb9R;/Z*+(K[@0lTPlpS]P>ftDJ(Yd,j)e"X6]Mh=8cc;g/bj="RD,(hJDG'Rf2u&]+sgcOK;4d>(;EcS@?Y*d@J2n$9?^jGuQV64Ng(]?CqPE].3YPK/1ou:t?VY5D-,qZ51'7WYG?Ig4Qs]dZshQ?21YO222N]NNn%#bLAipDS1V)cp_%"TI[Cs'me4AHI*Bf$Pkee$=.b5NL"2#7[Gj6Xjeo59MM(FJM(:=)dTI"#@4#.?(lnRcp:as6!*89QUb0`?(m1ZZ.BY#D0/KN45.=I\s@+6>p%e[$dE&$hC[!5C`f.0;riMhcBbH%CM_O6Z&56glTYfY?1+%Xfp(?-%@1m)-&%Dhmk/UbV>B-W?8=m,AS+nkC'uK<bFu])(?.'!lN4o1a7Q#"rHJupcca%^U?_+ug.M:EG\#<GdkI.(.-n9J5P"t#"BlY)N9L7iA?<=BVXI9'gOf/JD-HoV]qN0,].<]@Ip`nmK9ToEq,4_Qe@6P8IfTdR>:9~>endstreamendobjxref0 200000000000 65535 f 0000000061 00000 n 0000000112 00000 n 0000000219 00000 n 0000000331 00000 n 0000000536 00000 n 0000000651 00000 n 0000000856 00000 n 0000001061 00000 n 0000001266 00000 n 0000001471 00000 n 0000001677 00000 n 0000001747 00000 n 0000002039 00000 n 0000002130 00000 n 0000004583 00000 n 0000007301 00000 n 0000009648 00000 n 0000011950 00000 n 0000014934 00000 n trailer<</ID [<00c2933906a873bcc440e328debc6d32><00c2933906a873bcc440e328debc6d32>]% ReportLab generated PDF document -- digest (opensource)
/Info 12 0 R/Root 11 0 R/Size 20>>startxref17471%%EOF123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425"""Generate docs/WORKFLOW.pdf β how DeepFace Studio actually works end to end.
Kept in the repo so the document can be regenerated after the pipeline changes,instead of drifting away from the code the way a hand-drawn diagram would.
Run: python scripts/make_workflow_pdf.py"""import os
from reportlab.lib.pagesizes import A4from reportlab.lib.units import mmfrom reportlab.pdfgen import canvas
NAVY = (0.06, 0.09, 0.16)TEAL = (0.05, 0.58, 0.53)SLATE = (0.28, 0.33, 0.41)LIGHT = (0.95, 0.96, 0.97)BORDER = (0.80, 0.84, 0.88)AMBER = (0.85, 0.47, 0.05)
W, H = A4M = 18 * mm
def header(c, title, subtitle=None): c.setFillColorRGB(*NAVY) c.setFont("Helvetica-Bold", 17) c.drawString(M, H - M - 4, title) if subtitle: c.setFillColorRGB(*SLATE) c.setFont("Helvetica", 9.5) c.drawString(M, H - M - 19, subtitle) c.setStrokeColorRGB(*TEAL) c.setLineWidth(2) c.line(M, H - M - 26, W - M, H - M - 26) return H - M - 42
def footer(c, page, total): c.setFillColorRGB(*SLATE) c.setFont("Helvetica", 7.5) c.drawString(M, 12 * mm, "DeepFace Studio β project workflow") c.drawRightString(W - M, 12 * mm, f"{page} / {total}")
def box_height(body=None): """Height that fits a title plus these body lines, with even padding.""" return 24 + len(body or []) * 10 + 2
def box(c, x, y, w, h, title, body=None, fill=LIGHT, accent=TEAL, tsize=9.5): """ Rounded box with an accent bar; returns the y of its bottom edge. Pass h=None to size it from the body, so adding a line can't overflow it. """ if h is None: h = box_height(body) c.setFillColorRGB(*fill) c.setStrokeColorRGB(*BORDER) c.setLineWidth(0.8) c.roundRect(x, y - h, w, h, 3, stroke=1, fill=1) c.setFillColorRGB(*accent) c.roundRect(x, y - h, 3, h, 1.5, stroke=0, fill=1)
c.setFillColorRGB(*NAVY) c.setFont("Helvetica-Bold", tsize) c.drawString(x + 9, y - 12.5, title) if body: c.setFillColorRGB(*SLATE) c.setFont("Helvetica", 8.2) ty = y - 24 for line in body: c.drawString(x + 9, ty, line) ty -= 10 return y - h
def arrow(c, x, y1, y2, label=None): c.setStrokeColorRGB(*TEAL) c.setLineWidth(1.2) c.line(x, y1, x, y2) c.setFillColorRGB(*TEAL) c.setLineWidth(0) p = c.beginPath() p.moveTo(x, y2) p.lineTo(x - 3.2, y2 + 6) p.lineTo(x + 3.2, y2 + 6) p.close() c.drawPath(p, stroke=0, fill=1) if label: c.setFillColorRGB(*SLATE) c.setFont("Helvetica-Oblique", 7.5) c.drawString(x + 8, (y1 + y2) / 2 - 2, label)
def bullets(c, x, y, items, width_note=None): c.setFont("Helvetica", 9) for it in items: c.setFillColorRGB(*TEAL) c.drawString(x, y, "β’") c.setFillColorRGB(*SLATE) c.drawString(x + 10, y, it) y -= 12.5 return y
# ββ page 1 β overview ββββββββββββββββββββββββββββββββββββββββββββββββββββββββdef page_overview(c): y = header(c, "DeepFace Studio", "AI face swap that places a visitor into a real campus photograph")
c.setFillColorRGB(*SLATE) c.setFont("Helvetica", 9.2) for line in [ "A visitor enters their name, uploads or captures a photo, and picks a campus location.", "Their face is swapped into the curated photograph for that location, then returned as a", "preview plus a high-resolution download.", ]: c.drawString(M, y, line) y -= 12.5 y -= 8
y = box(c, M, y, W - 2 * M, None, "Tech stack", [ "Frontend React 18 + Vite + TailwindCSS + Framer Motion (SPA, served by Flask)", "Backend Python + Flask, background worker threads for the swap pipeline", "Storage Supabase (location photographs) with a local Location/ folder fallback", "Auth Firebase Google Sign-In β gates the Control Panel to an email allowlist", ]) - 14
y = box(c, M, y, W - 2 * M, None, "Models", [ "buffalo_l (InsightFace) face detection + 5-point landmarks", "inswapper_128 (InsightFace) the identity swap itself, internally 128x128", "GFPGAN v1.4 restores facial detail lost to that 128px bottleneck", "RealESRGAN x4plus super-resolution, applied to the head region", "BiSeNet (facexlib) hair / skin / neck segmentation", "HairFastGAN (hosted Space) optional hairstyle transfer β needs HF_TOKEN", ]) - 14
y = box(c, M, y, W - 2 * M, None, "Hosting", [ "Hugging Face Space aditya-rAj19/FaceSWAP (Docker SDK, port 7860)", "Live https://aditya-raj19-faceswap.hf.space", "Hardware cpu-basic (free tier); CUDA is used automatically when present", "Deploy every push to main, via GitHub Actions", ]) - 14
box(c, M, y, W - 2 * M, None, "Why the pipeline is built the way it is", [ "The swap model works at 128x128, so the head is the only part of the frame that", "loses real detail. Everything else is taken from the original photograph untouched,", "and super-resolution is spent on the head alone rather than the whole image.", ], fill=(0.98, 0.96, 0.90), accent=AMBER)
# ββ page 2 β architecture ββββββββββββββββββββββββββββββββββββββββββββββββββββdef page_architecture(c): y = header(c, "System architecture", "What talks to what, at request time")
cw = W - 2 * M y = box(c, M, y, cw, None, "Browser β React SPA", [ "/ landing /app swap page (Head Swap toggle) /admin Control Panel", ]) arrow(c, W / 2, y, y - 22, "HTTPS") y -= 22
y = box(c, M, y, cw, None, "Flask (web_app.py)", [ "Serves the built SPA and the JSON API. Static assets get explicit MIME types", "because the slim Python image ships an incomplete MIME database.", ]) arrow(c, W / 2, y, y - 22, "submit / poll") y -= 22
half = (cw - 10) / 2 y2 = box(c, M, y, half, None, "Job store (in memory)", [ "One swap at a time β the", "models already saturate the", "2 vCPUs. Results expire after", "20 minutes and are capped.", ]) box(c, M + half + 10, y, half, None, "Worker thread", [ "_perform_swap() runs the", "pipeline with no request", "context and reports progress", "back to the job.", ]) y = y2 arrow(c, W / 2, y, y - 22) y -= 22
y = box(c, M, y, cw, None, "core/ pipeline", [ "detector Β· swapper Β· super_res Β· head_swap Β· segmentor Β· blender Β· hair_transfer", ]) y -= 16
y2 = box(c, M, y, half, None, "Supabase", [ "Location photographs per", "gender. Falls back to the", "Location/ folder when unset.", ], accent=SLATE) box(c, M + half + 10, y, half, None, "Firebase", [ "Google Sign-In for the", "Control Panel; ID tokens are", "verified server-side too.", ], accent=SLATE)
c.setFillColorRGB(*SLATE) c.setFont("Helvetica-Oblique", 8) c.drawString(M, y2 - 16, "Nothing is written to disk during a swap β images are decoded, processed and returned in memory.")
# ββ page 3 β request flow ββββββββββββββββββββββββββββββββββββββββββββββββββββdef page_request(c): y = header(c, "Request workflow", "Why a swap is a job rather than a single request")
box(c, M, y, W - 2 * M, None, "The constraint", [ "Full-quality output takes minutes on the free CPU tier β head super-resolution alone", "is about six. No HTTP request survives that, so the swap cannot be synchronous.", ], fill=(0.98, 0.96, 0.90), accent=AMBER) y -= 62
steps = [ ("1 POST /api/swap", [ "Validates and decodes the source, resolves the target from gender + location,", "creates a job and returns 202 with a job_id. Returns in about 1.5 seconds.", ]), ("2 Worker thread picks up the job", [ "Runs the pipeline, updating progress and a message at each stage.", ]), ("3 GET /api/swap/status/<job_id>", [ "Polled every 2 seconds. Returns state, progress and message while running.", ]), ("4 state = done", [ "The same payload the endpoint always returned: result_image, download_image,", "quality, delta_e, src_tone, tgt_tone, warnings, name.", ]), ] for i, (title, body) in enumerate(steps): y = box(c, M, y, W - 2 * M, None, title, body) if i < len(steps) - 1: arrow(c, W / 2, y, y - 18) y -= 18 y -= 20
c.setFillColorRGB(*NAVY) c.setFont("Helvetica-Bold", 11) c.drawString(M, y, "In the UI") y -= 16 bullets(c, M, y, [ "The progress bar follows the server's real stage, not a timer animating a guess.", "The motivational captions keep rotating on their own β the wait is longer now.", "Failures surface the server's message instead of failing silently.", ])
# ββ page 4 β the pipeline ββββββββββββββββββββββββββββββββββββββββββββββββββββdef page_pipeline(c): y = header(c, "The swap pipeline", "Stage by stage, with measured CPU cost on a 1086x1448 photograph")
c.setFillColorRGB(*SLATE) c.setFont("Helvetica", 8.6) c.drawString(M, y, "Working resolution is 1024 on CPU and 1536 on CUDA. Optional stages are marked.") y -= 16
rows = [ ("Prepare", "Resize; pad a close-up until detectable; de-roll a tilted selfie so eyes are level.", "~7s"), ("Detect", "buffalo_l on source and target; retries with CLAHE, then Haar.", "~1s"), ("Head swap (opt-in)", "Transplants the whole head β shape and hair β instead of only the face.", "varies"), ("Face swap", "inswapper_128 puts the source identity on the main target face.", "~19s"), ("Restore", "GFPGAN rebuilds the detail the 128px swap threw away.", "~55s"), ("Blend seam", "Laplacian pyramid over the face boundary. Must run before hair.", "~14s"), ("Hair (opt-in)", "HairFastGAN only. No crude fallback β it smeared a blob over the head.", "~30s"), ("Glasses (opt-in)", "Off by default: it disfigured sources who wear glasses.", "~4s"), ("Skin tone", "Drives face, neck, arms and hands to the source complexion.", "~3s"), ("Score", "Alignment, blend, delta-E, naturalness β measured before grain is added.", "~2s"), ("Harmonise", "Adds the photo's grain over the parsed head so it isn't GAN-smooth.", "~1s"), ("Composite", "Pastes only what changed back onto the untouched full-resolution photo.", "~0.2s"), ("Enhance", "RealESRGAN on the head crop, Lanczos elsewhere, feathered between.", "~370s"), ]
c.setFillColorRGB(*NAVY) c.setFont("Helvetica-Bold", 8.4) c.drawString(M + 4, y, "STAGE") c.drawString(M + 108, y, "WHAT IT DOES") c.drawRightString(W - M - 4, y, "CPU") y -= 4 c.setStrokeColorRGB(*BORDER) c.setLineWidth(0.6) c.line(M, y, W - M, y) y -= 13
for i, (name, desc, cost) in enumerate(rows): if i % 2 == 0: c.setFillColorRGB(0.975, 0.98, 0.985) c.rect(M, y - 4, W - 2 * M, 15, stroke=0, fill=1) opt = "(opt-in)" in name c.setFillColorRGB(*(SLATE if opt else NAVY)) c.setFont("Helvetica-Bold", 8.2) c.drawString(M + 4, y, name) c.setFillColorRGB(*SLATE) c.setFont("Helvetica", 8) c.drawString(M + 108, y, desc) c.setFillColorRGB(*(AMBER if cost == "~370s" else SLATE)) c.setFont("Helvetica-Bold" if cost == "~370s" else "Helvetica", 8) c.drawRightString(W - M - 4, y, cost) y -= 15
y -= 12 box(c, M, y, W - 2 * M, None, "The two decisions that matter most", [ "Composite, not upscale β the background and body are never touched by the swap, so", "they are taken from the original photograph. Background sharpness went from 34% of", "the original to 100%, and the delivered image is native resolution rather than a", "downscaled frame blown back up.", ], fill=(0.94, 0.98, 0.97))
# ββ page 5 β deployment ββββββββββββββββββββββββββββββββββββββββββββββββββββββdef page_deploy(c): y = header(c, "Deployment", "From a push on main to a running Space")
seq = [ ("git push origin main", ["The default branch is the deploy trigger."]), ("GitHub Actions", [ "ci.yml pytest on a lightweight dependency subset, plus a frontend build", "deploy.yml force-pushes the repository to the Hugging Face Space", ]), ("Hugging Face Space", [ "Rebuilds the Docker image on the new commit.", ]), ("Docker build", [ "Stage 1 node:20-slim builds the React app into static/react", "Stage 2 python:3.10-slim installs CPU torch, then requirements-deploy.txt", ]), ("startup.sh", [ "Downloads model weights in the BACKGROUND and starts Flask immediately β", "a container that doesn't answer on its port within ~60s is killed.", ]), ("Flask on :7860", [ "Debug off; models pre-warm on a daemon thread so the port binds at once.", ]), ] for i, (title, body) in enumerate(seq): y = box(c, M, y, W - 2 * M, None, title, body) if i < len(seq) - 1: arrow(c, W / 2, y, y - 16) y -= 16 y -= 22
c.setFillColorRGB(*NAVY) c.setFont("Helvetica-Bold", 11) c.drawString(M, y, "Configuration held outside the repository") y -= 16 y = bullets(c, M, y, [ "HF_TOKEN β GitHub secret for deploying; also lifts the HairFastGAN GPU quota.", "SUPABASE_URL / SUPABASE_SERVICE_KEY / SUPABASE_BUCKET β location photographs.", "ALLOWED_ADMIN_EMAILS / PRIMARY_ADMIN_EMAILS β Control Panel access.", "FLASK_DEBUG β unset in production; set to true only for local development.", ]) y -= 6 box(c, M, y, W - 2 * M, None, "Verifying a deploy", [ "Space state and commit: https://huggingface.co/api/spaces/aditya-rAj19/FaceSWAP/runtime", "Expect \"stage\":\"RUNNING\" with sha matching the pushed commit, then probe / and /api/locations.", ], fill=(0.94, 0.98, 0.97))
# ββ page 6 β behaviour + gotchas βββββββββββββββββββββββββββββββββββββββββββββdef page_notes(c): y = header(c, "Behaviour and known limits", "Things that are easy to misread from the code")
y = box(c, M, y, W - 2 * M, None, "CPU and GPU", [ "Both paths run the same pipeline; only cost and working resolution differ.", "CPU 1024px working resolution; RealESRGAN on the head crop (~6 min).", "GPU 1536px; RealESRGAN available for the full frame; local HairFastGAN possible.", "Full-frame super-resolution on CPU was measured at about 20 minutes, which is why", "it is confined to the head.", ]) - 14
y = box(c, M, y, W - 2 * M, None, "Hair transfer", [ "Real hair transfer requires HairFastGAN. On the Space it connects to the public", "AIRI-Institute/HairFastGAN ZeroGPU Space anonymously and hits its quota, so it fails", "and the target's own hair is kept.", "", "To enable it: set HF_TOKEN on the Space, or point HAIRFAST_SPACE at your own GPU", "Space. There is deliberately no fallback β warping hair in directly looked pasted.", ], fill=(0.98, 0.96, 0.90), accent=AMBER) - 14
y = box(c, M, y, W - 2 * M, None, "Opt-in stages, and why", [ "Head swap changes far more of the photo than a face swap; exposed as a toggle.", "Hair only runs when HairFastGAN returns a portrait.", "Glasses warped spectacles onto the face as a misaligned, translucent shape.", "Each is a form field on /api/swap, so any of them can be turned back on per request.", ]) - 14
y = box(c, M, y, W - 2 * M, None, "Quality metrics", [ "Reported per swap: alignment, blend, delta-E and naturalness. They are computed", "BEFORE the harmonise stage β that stage adds grain deliberately, and scoring after it", "penalised the pipeline for its own noise, understating every result.", ]) - 14
box(c, M, y, W - 2 * M, None, "Privacy", [ "Uploads are decoded in memory and the result is returned as a data URI; nothing is", "written to disk. Finished jobs, which hold the images, expire after 20 minutes.", ])
def main(): out_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "docs") os.makedirs(out_dir, exist_ok=True) path = os.path.join(out_dir, "WORKFLOW.pdf")
pages = [page_overview, page_architecture, page_request, page_pipeline, page_deploy, page_notes]
c = canvas.Canvas(path, pagesize=A4) c.setTitle("DeepFace Studio β project workflow") c.setAuthor("Aditya Raj") for i, page in enumerate(pages, 1): page(c) footer(c, i, len(pages)) c.showPage() c.save() print(f"wrote {path}")
if __name__ == "__main__": main()