Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .idea/.gitignore

This file was deleted.

12 changes: 0 additions & 12 deletions .idea/ganrec.iml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/inspectionProfiles/profiles_settings.xml

This file was deleted.

4 changes: 0 additions & 4 deletions .idea/misc.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

116 changes: 47 additions & 69 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,115 +1,80 @@
# GANrec: A GAN-based Data Reconstruction Framework
# GANrec: A GAN-based data reconstruction framework

# Overview
## Overview

GANrec is an data reconstruction framework that harnesses the power of Generative Adversarial Networks (GANs). While traditional reconstruction methods primarily rely on intricate algorithms to piece together fragmented data, GANrec employs the generative capabilities of GANs to reimagine and revitalize data reconstruction.

Originally designed for the fields of tomography and phase retrieval, GANrec shines in its adaptability. With a provision to input the forward model, the framework can be flexibly adapted for complex data reconstruction processes across diverse applications.

# Features
## Features

1. GAN-powered Reconstruction: At its core, GANrec employs GANs to assist in the reconstruction process, enabling more accurate and efficient results than conventional methods.
2. Specialized for Tomography & Phase Retrieval: GANrec has been optimized for tomography and phase retrieval applications, ensuring precision and reliability in these domains.
3. Modular Design: The framework's architecture allows users to provide their forward model, making it adaptable for various complex data reconstruction challenges.
4. Efficient and Scalable: Built to handle large datasets, GANrec ensures that speed and efficiency are maintained without compromising the accuracy of reconstruction.

# Installation
## Installation

This guide provides two ways to set up `ganrec`:
- With Pixi (recommended, reproducible): default TensorFlow+CUDA backend with an optional PyTorch-only backend.
- With Conda/pip (alternative): manual setup.

## Pixi (recommended)
### Pixi (recommended)

Pixi manages environments and dependencies declaratively via `pyproject.toml`.

- Default backend (TensorFlow with CUDA extras):
- Default backend (TensorFlow with CUDA extras; no PyTorch):

```bash
pixi install
pixi run python -c "import tensorflow as tf; print(tf.__version__)"
```

- Optional PyTorch backend (no TensorFlow):

```bash
pixi -e pytorch install
pixi -e pytorch run python -c "import torch; print(torch.__version__)"
```

Notes:
- The default Pixi environment installs TensorFlow with GPU support (via pip extra) and does not install PyTorch.
- The `pytorch` Pixi environment installs PyTorch-only and does not install TensorFlow.
- `ipython`/`ipykernel` are included so you can create a kernel for notebooks if needed.

## Steps for General Users

### 1. Create & Activate a Conda Environment
Open your terminal or command prompt and create a new conda environment named `ganrec` with Python 3.11:

```bash
conda create --name ganrec python=3.11
conda activate ganrec
```

### 2. Install Tensorflow OR Pytorch
Choose and install either TensorFlow or PyTorch based on your preference.
Quick start with Pixi:

For TensorFlow:
```bash
pip install tensorflow
```
1) Install Pixi (see https://pixi.sh)
2) Clone this repo and enter it:
- git clone https://github.com/XYangXRay/ganrec.git && cd ganrec
3) Install the default environment (TensorFlow):
- pixi install
4) Or install the PyTorch environment only:
- pixi -e pytorch install
5) Run examples:
- pixi run python examples/holography_tf.py
- pixi -e pytorch run python examples/tomography_torch.py

For PyTorch (make sure to select the correct version for your system from the PyTorch website):
```bash
# Example command for installing PyTorch with CUDA support
pip install torch torchvision torchaudio
```
Note: Environments are defined in `pyproject.toml` — `default` uses TensorFlow; `pytorch` uses PyTorch.

### 3. Install 'ganrec' from PyPI
Finally, install the ganrec package from PyPI:
```bash
pip install ganrec
```
### Conda environment

## Steps for developers:
If you want to work for some developments based on GANrec, please follow the steps below to install and set up GANrec:


### 1. Create & Activate a Conda Environment
#### 1. Create & Activate a Conda Environment
Open your terminal or command prompt and create a new conda environment named `ganrec` with Python 3.11:

```bash
conda create --name ganrec python=3.11
conda activate ganrec
```

### 2. Install Tensorflow OR PyTorch
Choose and install either TensorFlow or PyTorch based on your preference.

For TensorFlow:
```bash
pip install tensorflow
```
#### 2. Install ganrec with your preferred backend (recommended)
Use pip extras to install GANrec and the backend in one step:

For PyTorch (make sure to select the correct version for your system from the PyTorch website):
```bash
# Example command for installing PyTorch with CUDA support
pip install torch torchvision torchaudio
```
### 3. Clone the GANrec Repository:
Clone the GANrec repository from GitHub to your local machine.
```bash
git clone https://github.com/XYangXRay/ganrec.git`
# TensorFlow backend
pip install "ganrec[tensorflow]"

# PyTorch backend
pip install "ganrec[pytorch]"
```

### 4. Install the Required Packages:
Notes:
- For TensorFlow GPU wheels, see TensorFlow’s docs (e.g., tensorflow[and-cuda]) and ensure compatible NVIDIA drivers/CUDA.
- For PyTorch, use the selector on pytorch.org for OS/CUDA-specific commands if the generic wheel doesn’t match your system.

Navigate to the main directory of the cloned repository and install the necessary packages.
```bash
cd ganrec
python3 -m pip install -e .
```

## Additional Notes for Users

Expand All @@ -120,16 +85,29 @@ PyTorch is favored for its ease of use, dynamic computation graph, and strong su
### Installing GPU Support
ganrec requires heavy duty work with GPU, make sure to install the GPU versions of TensorFlow or PyTorch. Instructions for this can be found on the respective official websites (TensorFlow and PyTorch).

# Examples
## Examples

GANrec currently has the applications for tomography reconstructon and in-line phase contrast (holography) phase retrieval:
GANrec currently has applications for tomography reconstruction and in-line phase contrast (holography) phase retrieval:

1. X-ray tomography reconstruction:
- [Tomography Example](https://github.com/XYangXRay/ganrec/blob/main/examples/tomography_tf.ipynb)
2. Holography phase retreival:
2. Holography phase retrieval:
- [Phase retrieval Example](https://github.com/XYangXRay/ganrec/blob/main/examples/holography_tf.ipynb)

# References
You can also run the Python examples directly:

```bash
# TensorFlow tomography example
pixi run python examples/tomography_tf.py

# TensorFlow holography example
pixi run python examples/holography_tf.py

# PyTorch tomography example
pixi -e pytorch run python examples/tomography_torch.py
```

## References

If you find GANrec is useful in your work, please consider citing:

Expand Down
20 changes: 0 additions & 20 deletions README.rst

This file was deleted.

17 changes: 0 additions & 17 deletions requirements-dev.txt

This file was deleted.

10 changes: 0 additions & 10 deletions requirements.txt

This file was deleted.

11 changes: 0 additions & 11 deletions setup.cfg

This file was deleted.

68 changes: 0 additions & 68 deletions setup.py

This file was deleted.

Loading
Loading