Spaces:
Running
on
Zero
Running
on
Zero
Update style_transfer.py
Browse files- style_transfer.py +3 -0
style_transfer.py
CHANGED
|
@@ -15,6 +15,7 @@ from diffusers import StableDiffusionImg2ImgPipeline
|
|
| 15 |
import time
|
| 16 |
import os
|
| 17 |
import base64
|
|
|
|
| 18 |
from io import BytesIO
|
| 19 |
|
| 20 |
class DogStyleTransfer:
|
|
@@ -118,6 +119,7 @@ class DogStyleTransfer:
|
|
| 118 |
print(f"xformers available: {self.xformers_available}")
|
| 119 |
print("============================\n")
|
| 120 |
|
|
|
|
| 121 |
def load_model(self, style_name):
|
| 122 |
"""Load the appropriate model based on style, handling xformers compatibility"""
|
| 123 |
|
|
@@ -207,6 +209,7 @@ class DogStyleTransfer:
|
|
| 207 |
|
| 208 |
return image
|
| 209 |
|
|
|
|
| 210 |
def transform_style(self, image, style_name, strength=0.75, guidance_scale=7.5):
|
| 211 |
"""
|
| 212 |
Transform image to selected style with improved prompts and parameters
|
|
|
|
| 15 |
import time
|
| 16 |
import os
|
| 17 |
import base64
|
| 18 |
+
import spaces
|
| 19 |
from io import BytesIO
|
| 20 |
|
| 21 |
class DogStyleTransfer:
|
|
|
|
| 119 |
print(f"xformers available: {self.xformers_available}")
|
| 120 |
print("============================\n")
|
| 121 |
|
| 122 |
+
@spaces.GPU
|
| 123 |
def load_model(self, style_name):
|
| 124 |
"""Load the appropriate model based on style, handling xformers compatibility"""
|
| 125 |
|
|
|
|
| 209 |
|
| 210 |
return image
|
| 211 |
|
| 212 |
+
@spaces.GPU
|
| 213 |
def transform_style(self, image, style_name, strength=0.75, guidance_scale=7.5):
|
| 214 |
"""
|
| 215 |
Transform image to selected style with improved prompts and parameters
|