# akmalhfzh/image_inpainting_gan architecture

> Architecture diagram of the GitHub repository akmalhfzh/image_inpainting_gan, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/akmalhfzh/image_inpainting_gan
- Repository: https://github.com/akmalhfzh/image_inpainting_gan

## Overview

This repository implements an image-inpainting Context Encoder GAN, spanning PyTorch training and inference, fixed-point weight preparation, a custom Verilog accelerator, and PYNQ deployment. The main user workflow is to provide an image, mask a region, run generator inference, and obtain a completed image; the training-to-hardware path prepares weights for the FPGA. The README documents these capabilities, but most RTL and deployment internals were not excerpted, so the graph avoids asserting unsampled module-level call relationships.

Main entry points: [`Software_Deployment/USB_GAN/pynq_runner.py`](https://github.com/akmalhfzh/image_inpainting_gan/blob/main/Software_Deployment/USB_GAN/pynq_runner.py) (PYNQ Runner), [`Model_Training_and_Inference/train/train.py`](https://github.com/akmalhfzh/image_inpainting_gan/blob/main/Model_Training_and_Inference/train/train.py) (GAN Training), [`Model_Training_and_Inference/train/extract_weights.py`](https://github.com/akmalhfzh/image_inpainting_gan/blob/main/Model_Training_and_Inference/train/extract_weights.py) (Weight Export), [`Model_Training_and_Inference/train/models.py`](https://github.com/akmalhfzh/image_inpainting_gan/blob/main/Model_Training_and_Inference/train/models.py) (GAN Models)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_model["Model and Training"]
  node_train["GAN Training<br/>[train.py]"]
  node_modeldef["GAN Models<br/>[models.py]"]
  node_swinfer["Software Inference<br/>[inference.py]"]
  node_weightx["Weight Export<br/>[extract_weights.py]"]
end

subgraph group_hardware["FPGA Accelerator"]
  node_weights["RTL Weight Images"]
  node_rtl_top["Generator Top<br/>[generator_top.v]"]
  node_axi["AXI Wrapper<br/>[gan_axi_wrapper.v]"]
  node_conv["Convolution Engine<br/>[conv_unified.v]"]
  node_mac["MAC Array<br/>[mac_array.v]"]
  node_batchnorm["Batch Normalization<br/>[batchnorm2d.v]"]
  node_activations["Activations"]
end

subgraph group_deploy["PYNQ Deployment"]
  node_runner["PYNQ Runner<br/>[pynq_runner.py]"]
  node_mask["Mask Utilities<br/>[apply_mask.py]"]
end

subgraph group_verify["Verification"]
  node_refmodel["Reference Model<br/>[models.py]"]
  node_verifyinfer["Reference Inference<br/>[inference.py]"]
  node_check["Output Checks<br/>[check_gen.py]"]
  node_visualize["RTL Visualization"]
end

node_user(("Image User"))
node_fpga{{"Zynq FPGA"}}
node_result["Inpainted Image"]

node_train -->|"trains"| node_modeldef
node_swinfer -->|"runs generator"| node_modeldef
node_train -.->|"exports weights"| node_weightx
node_weightx -.->|"writes hex"| node_weights
node_user -->|"submits image"| node_runner
node_runner -->|"runs accelerator"| node_fpga
node_mask -.->|"prepares mask"| node_runner
node_fpga -->|"returns image"| node_result
node_verifyinfer -->|"runs reference"| node_refmodel
node_check -.->|"checks output"| node_result
node_visualize -.->|"visualizes layers"| node_result

click node_train "https://github.com/akmalhfzh/image_inpainting_gan/blob/main/Model_Training_and_Inference/train/train.py"
click node_modeldef "https://github.com/akmalhfzh/image_inpainting_gan/blob/main/Model_Training_and_Inference/train/models.py"
click node_swinfer "https://github.com/akmalhfzh/image_inpainting_gan/blob/main/Model_Training_and_Inference/train/inference.py"
click node_weightx "https://github.com/akmalhfzh/image_inpainting_gan/blob/main/Model_Training_and_Inference/train/extract_weights.py"
click node_weights "https://github.com/akmalhfzh/image_inpainting_gan/tree/main/Hardware_Design/weight_hex"
click node_rtl_top "https://github.com/akmalhfzh/image_inpainting_gan/blob/main/Hardware_Design/rtl/generator_top.v"
click node_axi "https://github.com/akmalhfzh/image_inpainting_gan/blob/main/Hardware_Design/rtl/gan_axi_wrapper.v"
click node_conv "https://github.com/akmalhfzh/image_inpainting_gan/blob/main/Hardware_Design/rtl/conv_unified.v"
click node_mac "https://github.com/akmalhfzh/image_inpainting_gan/blob/main/Hardware_Design/rtl/mac_array.v"
click node_batchnorm "https://github.com/akmalhfzh/image_inpainting_gan/blob/main/Hardware_Design/rtl/batchnorm2d.v"
click node_activations "https://github.com/akmalhfzh/image_inpainting_gan/tree/main/Hardware_Design/rtl"
click node_runner "https://github.com/akmalhfzh/image_inpainting_gan/blob/main/Software_Deployment/USB_GAN/pynq_runner.py"
click node_mask "https://github.com/akmalhfzh/image_inpainting_gan/blob/main/Software_Deployment/USB_GAN/apply_mask.py"
click node_refmodel "https://github.com/akmalhfzh/image_inpainting_gan/blob/main/Verification_and_Scripts/verify/models.py"
click node_verifyinfer "https://github.com/akmalhfzh/image_inpainting_gan/blob/main/Verification_and_Scripts/verify/inference.py"
click node_check "https://github.com/akmalhfzh/image_inpainting_gan/blob/main/Verification_and_Scripts/verify/check_gen.py"
click node_visualize "https://github.com/akmalhfzh/image_inpainting_gan/blob/main/Verification_and_Scripts/verify/visualize_rtl_hex.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_train,node_modeldef,node_swinfer,node_weightx,node_user toneBlue
class node_weights,node_rtl_top,node_axi,node_conv,node_mac,node_batchnorm,node_activations toneAmber
class node_runner,node_mask toneMint
class node_refmodel,node_verifyinfer,node_check,node_visualize toneRose
class node_fpga,node_result toneIndigo
```

## Components

### Model and Training

- [GAN Training](https://github.com/akmalhfzh/image_inpainting_gan/blob/main/Model_Training_and_Inference/train/train.py): `Model_Training_and_Inference/train/train.py`
- [GAN Models](https://github.com/akmalhfzh/image_inpainting_gan/blob/main/Model_Training_and_Inference/train/models.py): `Model_Training_and_Inference/train/models.py`
- [Software Inference](https://github.com/akmalhfzh/image_inpainting_gan/blob/main/Model_Training_and_Inference/train/inference.py): `Model_Training_and_Inference/train/inference.py`
- [Weight Export](https://github.com/akmalhfzh/image_inpainting_gan/blob/main/Model_Training_and_Inference/train/extract_weights.py): `Model_Training_and_Inference/train/extract_weights.py`

### FPGA Accelerator

- [RTL Weight Images](https://github.com/akmalhfzh/image_inpainting_gan/tree/main/Hardware_Design/weight_hex): `Hardware_Design/weight_hex`
- [Generator Top](https://github.com/akmalhfzh/image_inpainting_gan/blob/main/Hardware_Design/rtl/generator_top.v): `Hardware_Design/rtl/generator_top.v`
- [AXI Wrapper](https://github.com/akmalhfzh/image_inpainting_gan/blob/main/Hardware_Design/rtl/gan_axi_wrapper.v): `Hardware_Design/rtl/gan_axi_wrapper.v`
- [Convolution Engine](https://github.com/akmalhfzh/image_inpainting_gan/blob/main/Hardware_Design/rtl/conv_unified.v): `Hardware_Design/rtl/conv_unified.v`
- [MAC Array](https://github.com/akmalhfzh/image_inpainting_gan/blob/main/Hardware_Design/rtl/mac_array.v): `Hardware_Design/rtl/mac_array.v`
- [Batch Normalization](https://github.com/akmalhfzh/image_inpainting_gan/blob/main/Hardware_Design/rtl/batchnorm2d.v): `Hardware_Design/rtl/batchnorm2d.v`
- [Activations](https://github.com/akmalhfzh/image_inpainting_gan/tree/main/Hardware_Design/rtl): `Hardware_Design/rtl`

### PYNQ Deployment

- [PYNQ Runner](https://github.com/akmalhfzh/image_inpainting_gan/blob/main/Software_Deployment/USB_GAN/pynq_runner.py): `Software_Deployment/USB_GAN/pynq_runner.py`
- [Mask Utilities](https://github.com/akmalhfzh/image_inpainting_gan/blob/main/Software_Deployment/USB_GAN/apply_mask.py): `Software_Deployment/USB_GAN/apply_mask.py`

### Verification

- [Reference Model](https://github.com/akmalhfzh/image_inpainting_gan/blob/main/Verification_and_Scripts/verify/models.py): `Verification_and_Scripts/verify/models.py`
- [Reference Inference](https://github.com/akmalhfzh/image_inpainting_gan/blob/main/Verification_and_Scripts/verify/inference.py): `Verification_and_Scripts/verify/inference.py`
- [Output Checks](https://github.com/akmalhfzh/image_inpainting_gan/blob/main/Verification_and_Scripts/verify/check_gen.py): `Verification_and_Scripts/verify/check_gen.py`
- [RTL Visualization](https://github.com/akmalhfzh/image_inpainting_gan/blob/main/Verification_and_Scripts/verify/visualize_rtl_hex.py): `Verification_and_Scripts/verify/visualize_rtl_hex.py`

### Other components

- **Image User**
- **Zynq FPGA**
- **Inpainted Image**

## Connections

- GAN Training → GAN Models: trains (evidence: `Model_Training_and_Inference/train/train.py`)
- Software Inference → GAN Models: runs generator (evidence: `Model_Training_and_Inference/train/inference.py`)
- GAN Training → Weight Export: exports weights
- Weight Export → RTL Weight Images: writes hex
- Image User → PYNQ Runner: submits image (evidence: `README.md`)
- PYNQ Runner → Zynq FPGA: runs accelerator (evidence: `README.md`)
- Mask Utilities → PYNQ Runner: prepares mask
- Zynq FPGA → Inpainted Image: returns image (evidence: `README.md`)
- Reference Inference → Reference Model: runs reference (evidence: `Verification_and_Scripts/verify/inference.py`)
- Output Checks → Inpainted Image: checks output
- RTL Visualization → Inpainted Image: visualizes layers
