Spaces:
Runtime error
Runtime error
Update random_charactor_generator.py
Browse files
random_charactor_generator.py
CHANGED
@@ -8,7 +8,34 @@ class RandomCharatorGeneratorTool:
|
|
8 |
|
9 |
outputs = ["json"]
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
def __call__(self, prompt):
|
|
|
|
|
|
|
12 |
API_URL = "https://randomuser.me/api/"
|
13 |
|
14 |
response = requests.get(API_URL)
|
|
|
8 |
|
9 |
outputs = ["json"]
|
10 |
|
11 |
+
|
12 |
+
def __init__(self, device=None, **hub_kwargs) -> None:
|
13 |
+
#if not is_accelerate_available():
|
14 |
+
# raise ImportError("Accelerate should be installed in order to use tools.")
|
15 |
+
|
16 |
+
super().__init__()
|
17 |
+
|
18 |
+
self.device = device
|
19 |
+
self.pipeline = None
|
20 |
+
self.hub_kwargs = hub_kwargs
|
21 |
+
|
22 |
+
def setup(self):
|
23 |
+
#if self.device is None:
|
24 |
+
# self.device = get_default_device()
|
25 |
+
|
26 |
+
#self.pipeline = DiffusionPipeline.from_pretrained(self.default_checkpoint)
|
27 |
+
#self.pipeline.scheduler = DPMSolverMultistepScheduler.from_config(self.pipeline.scheduler.config)
|
28 |
+
#self.pipeline.to(self.device)
|
29 |
+
|
30 |
+
#if self.device.type == "cuda":
|
31 |
+
# self.pipeline.to(torch_dtype=torch.float16)
|
32 |
+
|
33 |
+
self.is_initialized = True
|
34 |
+
|
35 |
def __call__(self, prompt):
|
36 |
+
if not self.is_initialized:
|
37 |
+
self.setup()
|
38 |
+
|
39 |
API_URL = "https://randomuser.me/api/"
|
40 |
|
41 |
response = requests.get(API_URL)
|