Spaces:
Sleeping
Sleeping
Yaron Koresh
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -24,11 +24,11 @@ else:
|
|
24 |
pipe = DiffusionPipeline.from_pretrained(model_id, use_safetensors=True)
|
25 |
pipe = pipe.to(device)
|
26 |
|
27 |
-
def
|
28 |
-
html_str = requests.get( url = "https://translate.google.com", params = {"sl": "
|
29 |
tree = fromstring(html_str)
|
30 |
-
|
31 |
-
return
|
32 |
|
33 |
def generate_random_string(length):
|
34 |
characters = string.ascii_letters + string.digits
|
@@ -37,7 +37,7 @@ def generate_random_string(length):
|
|
37 |
@spaces.GPU(25)
|
38 |
def infer(prompt):
|
39 |
name = generate_random_string(12)+".png"
|
40 |
-
image = pipe(
|
41 |
return name
|
42 |
|
43 |
css="""
|
|
|
24 |
pipe = DiffusionPipeline.from_pretrained(model_id, use_safetensors=True)
|
25 |
pipe = pipe.to(device)
|
26 |
|
27 |
+
def translate(text,lang):
|
28 |
+
html_str = requests.get( url = "https://translate.google.com", params = {"sl": "auto", "tl": lang, "op": "translate", "text": text} ).text()
|
29 |
tree = fromstring(html_str)
|
30 |
+
translated = tree.xpath('span[lang="'+lang+'"]/span/span/text()')[0]
|
31 |
+
return translated
|
32 |
|
33 |
def generate_random_string(length):
|
34 |
characters = string.ascii_letters + string.digits
|
|
|
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)
|
41 |
return name
|
42 |
|
43 |
css="""
|