Spaces:
Runtime error
Runtime error
Commit
·
9c06083
1
Parent(s):
b4808d1
update
Browse files- app.py +12 -10
- requirements.txt +2 -2
app.py
CHANGED
|
@@ -6,16 +6,18 @@ import random
|
|
| 6 |
import transformers
|
| 7 |
import numpy as np
|
| 8 |
from transformers import T5Tokenizer, T5ForConditionalGeneration
|
| 9 |
-
import
|
|
|
|
| 10 |
|
| 11 |
-
HF_TOKEN = os.getenv("HF_TOKEN")
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
| 19 |
|
| 20 |
|
| 21 |
MAX_SEED = np.iinfo(np.int32).max
|
|
@@ -31,7 +33,7 @@ model = T5ForConditionalGeneration.from_pretrained("roborovski/superprompt-v1",
|
|
| 31 |
model.to(device)
|
| 32 |
|
| 33 |
# Define the image generation function
|
| 34 |
-
|
| 35 |
def generate_image(prompt, enhance_prompt, negative_prompt, num_inference_steps, height, width, guidance_scale, seed, num_images_per_prompt):
|
| 36 |
if seed == 0:
|
| 37 |
seed = random.randint(1, 2**32-1)
|
|
@@ -96,4 +98,4 @@ interface = gr.Interface(
|
|
| 96 |
)
|
| 97 |
|
| 98 |
# Launch the interface
|
| 99 |
-
interface.launch(share = False)
|
|
|
|
| 6 |
import transformers
|
| 7 |
import numpy as np
|
| 8 |
from transformers import T5Tokenizer, T5ForConditionalGeneration
|
| 9 |
+
import devicetorch
|
| 10 |
+
#import spaces
|
| 11 |
|
| 12 |
+
#HF_TOKEN = os.getenv("HF_TOKEN")
|
| 13 |
|
| 14 |
+
device = devicetorch.get(torch)
|
| 15 |
+
#if torch.cuda.is_available():
|
| 16 |
+
# device = "cuda"
|
| 17 |
+
# print("Using GPU")
|
| 18 |
+
#else:
|
| 19 |
+
# device = "cpu"
|
| 20 |
+
# print("Using CPU")
|
| 21 |
|
| 22 |
|
| 23 |
MAX_SEED = np.iinfo(np.int32).max
|
|
|
|
| 33 |
model.to(device)
|
| 34 |
|
| 35 |
# Define the image generation function
|
| 36 |
+
#@spaces.GPU(duration=60)
|
| 37 |
def generate_image(prompt, enhance_prompt, negative_prompt, num_inference_steps, height, width, guidance_scale, seed, num_images_per_prompt):
|
| 38 |
if seed == 0:
|
| 39 |
seed = random.randint(1, 2**32-1)
|
|
|
|
| 98 |
)
|
| 99 |
|
| 100 |
# Launch the interface
|
| 101 |
+
interface.launch(share = False)
|
requirements.txt
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
-
torch
|
| 2 |
diffusers
|
| 3 |
transformers
|
| 4 |
accelerate
|
| 5 |
sentencepiece
|
| 6 |
numpy
|
| 7 |
-
gradio==4.36.0
|
|
|
|
| 1 |
+
#torch
|
| 2 |
diffusers
|
| 3 |
transformers
|
| 4 |
accelerate
|
| 5 |
sentencepiece
|
| 6 |
numpy
|
| 7 |
+
gradio==4.36.0
|