Instructions to use Saad381/SpectraGen with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use Saad381/SpectraGen with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", dtype=torch.bfloat16, device_map="cuda") pipe.load_lora_weights("Saad381/SpectraGen") prompt = "Goku" image = pipe(prompt).images[0] - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Draw Things
- DiffusionBee
Upload train.py
Browse files
train.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import AutoModel, AutoTokenizer, Trainer, TrainingArguments
|
| 2 |
+
from datasets import load_dataset
|
| 3 |
+
import pandas as pd
|
| 4 |
+
|
| 5 |
+
# Load model and tokenizer
|
| 6 |
+
model = AutoModel.from_pretrained('Anime.safetensors', trust_remote_code=True)
|
| 7 |
+
tokenizer = AutoTokenizer.from_pretrained('Saad381/SpectraGen')
|
| 8 |
+
|
| 9 |
+
# Load dataset
|
| 10 |
+
dataset = load_dataset('csv', data_files='dataset.csv')
|
| 11 |
+
|
| 12 |
+
# Set training arguments
|
| 13 |
+
training_args = TrainingArguments(
|
| 14 |
+
output_dir='./results',
|
| 15 |
+
per_device_train_batch_size=8,
|
| 16 |
+
num_train_epochs=3,
|
| 17 |
+
evaluation_strategy="epoch"
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
# Initialize Trainer
|
| 21 |
+
trainer = Trainer(
|
| 22 |
+
model=model,
|
| 23 |
+
args=training_args,
|
| 24 |
+
train_dataset=dataset['train']
|
| 25 |
+
)
|
| 26 |
+
|
| 27 |
+
# Train the model
|
| 28 |
+
trainer.train()
|
| 29 |
+
|
| 30 |
+
# Save the model
|
| 31 |
+
model.save_pretrained('./trained_model')
|
| 32 |
+
tokenizer.save_pretrained('./trained_model')
|