Yaron Koresh commited on
Commit
76b48d0
·
verified ·
1 Parent(s): 77a7037

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -5
app.py CHANGED
@@ -1,16 +1,15 @@
1
- import spaces
2
  import gradio as gr
3
  #from tempfile import NamedTemporaryFile
4
  import numpy as np
5
  import random
6
  from diffusers import StableDiffusionPipeline as DiffusionPipeline
7
  import torch
8
- #from pathos.multiprocessing import ProcessingPool as ProcessPoolExecutor
9
  import requests
10
  from lxml.html.soupparser import fromstring
11
 
12
- #pool = ProcessPoolExecutor(100)
13
- #pool.__enter__()
14
 
15
  model_id = "runwayml/stable-diffusion-v1-5"
16
 
@@ -34,7 +33,6 @@ def generate_random_string(length):
34
  characters = string.ascii_letters + string.digits
35
  return ''.join(random.choice(characters) for _ in range(length))
36
 
37
- @spaces.GPU(25)
38
  def infer(prompt):
39
  name = generate_random_string(12)+".png"
40
  image = pipe(translate(prompt,"en")).images[0].save(name)
 
 
1
  import gradio as gr
2
  #from tempfile import NamedTemporaryFile
3
  import numpy as np
4
  import random
5
  from diffusers import StableDiffusionPipeline as DiffusionPipeline
6
  import torch
7
+ from pathos.multiprocessing import ProcessingPool as ProcessPoolExecutor
8
  import requests
9
  from lxml.html.soupparser import fromstring
10
 
11
+ pool = ProcessPoolExecutor(4)
12
+ pool.__enter__()
13
 
14
  model_id = "runwayml/stable-diffusion-v1-5"
15
 
 
33
  characters = string.ascii_letters + string.digits
34
  return ''.join(random.choice(characters) for _ in range(length))
35
 
 
36
  def infer(prompt):
37
  name = generate_random_string(12)+".png"
38
  image = pipe(translate(prompt,"en")).images[0].save(name)