Spaces:
No application file
No application file
Create App.py
Browse files
App.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from diffusers import DiffusionPipeline, DPMSolverSinglestepScheduler
|
| 2 |
+
import torch
|
| 3 |
+
from transformers import TrainingArguments, Trainer
|
| 4 |
+
|
| 5 |
+
# Load the Mann-E Dreams model
|
| 6 |
+
pipe = DiffusionPipeline.from_pretrained("mann-e/Mann-E_Dreams", torch_dtype=torch.float16).to("cuda")
|
| 7 |
+
|
| 8 |
+
# Change the scheduler to improve results
|
| 9 |
+
pipe.scheduler = DPMSolverSinglestepScheduler.from_config(pipe.scheduler.config, use_karras_sigmas=True)
|
| 10 |
+
|
| 11 |
+
# Load your dataset of images and text (this is a placeholder)
|
| 12 |
+
# You need to upload your own dataset or load it from the cloud.
|
| 13 |
+
my_dataset = None # This is where you'll load your custom dataset
|
| 14 |
+
|
| 15 |
+
# Define training arguments (batch size, epochs, etc.)
|
| 16 |
+
trainer = Trainer(
|
| 17 |
+
model=pipe, # This is the Mann-E Dreams model
|
| 18 |
+
args=TrainingArguments(
|
| 19 |
+
output_dir="./results",
|
| 20 |
+
per_device_train_batch_size=4,
|
| 21 |
+
num_train_epochs=3,
|
| 22 |
+
logging_dir="./logs",
|
| 23 |
+
logging_steps=10,
|
| 24 |
+
),
|
| 25 |
+
train_dataset=my_dataset,
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
# Start training the model with your custom dataset
|
| 29 |
+
trainer.train()
|
| 30 |
+
|
| 31 |
+
# You can deploy this model directly to Hugging Face
|