Abhiroop174 commited on
Commit
18115c6
·
verified ·
1 Parent(s): bc45f22

Update README.md

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