File size: 1,891 Bytes
621843d 18115c6 621843d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
---
license: mit
language:
- en
pipeline_tag: unconditional-image-generation
---
# galaxy_gen
`galaxy_gen` is a library to generate galaxy data/distributions. The models used are present in this page.
## Installation
You can install the package using pip:
```sh
pip install galaxy_gen
```
## Usage
Here is an example of how to use the galaxy_gen library:
```python
# example_usage.py
import torch
import matplotlib.pyplot as plt
import galaxy_gen
from galaxy_gen.sampler import load_model, generate_samples
import os
# Path to your saved model checkpoint.
model_path = os.path.join(os.path.dirname(galaxy_gen.__file__), 'models/sample_model')
device = 'cpu' # or 'cuda' if you have a GPU
# Load the model.
model = load_sample_model(model_path, device=device)
# Generate random samples.
samples = generate_samples(model)
# (Optional) Visualize the samples.
samples = samples.cpu().numpy()
fig, axes = plt.subplots(4, 4, figsize=(8, 8))
for i, ax in enumerate(axes.flatten()):
ax.imshow(samples[i][0], cmap='gray')
ax.axis('off')
plt.show()
```
Another expample to use the pre-trained model
```python
# example_usage.py
import torch
import matplotlib.pyplot as plt
from galaxy_gen.sampler import load_model, generate_metallicity_samples, generate_formationtime_samples
# Path to your saved model checkpoint.
model_path = 'models/formationtime_model.pth'
device = 'cpu' # or 'cuda' if you have a GPU
# Load the model.
model = load_model("formation_time",model_path, device=device)
# Generate random samples.
samples = generate_formationtime_samples(model)
# (Optional) Visualize the samples.
samples = samples.cpu().numpy()
fig, axes = plt.subplots(4, 4, figsize=(8, 8))
for i, ax in enumerate(axes.flatten()):
ax.imshow(samples[i][0])
ax.axis('off')
plt.show()
```
## License
This project is licensed under the MIT License - see the LICENSE file for details. |