Spaces:
Running
Running
Yaron Koresh
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -6,7 +6,7 @@ import subprocess
|
|
6 |
import logging
|
7 |
import re
|
8 |
import random
|
9 |
-
from string import ascii_letters, digits
|
10 |
import requests
|
11 |
import sys
|
12 |
import warnings
|
@@ -18,15 +18,11 @@ from queue import Queue as BlockingQueue
|
|
18 |
|
19 |
# external
|
20 |
|
21 |
-
#import spaces
|
22 |
import torch
|
23 |
import gradio as gr
|
24 |
from numpy import asarray as array
|
25 |
from lxml.html import fromstring
|
26 |
-
#from transformers import pipeline
|
27 |
-
#from diffusers.pipelines.flux import FluxPipeline
|
28 |
from diffusers.utils import export_to_gif, load_image
|
29 |
-
from diffusers.models.modeling_utils import ModelMixin
|
30 |
from huggingface_hub import hf_hub_download
|
31 |
from safetensors.torch import load_file, save_file
|
32 |
from diffusers import DiffusionPipeline, AnimateDiffPipeline, MotionAdapter, EulerDiscreteScheduler, DDIMScheduler, StableDiffusionXLPipeline, UNet2DConditionModel, AutoencoderKL, UNet3DConditionModel
|
@@ -301,7 +297,7 @@ def translate(text,lang):
|
|
301 |
trgt_text = xpath_finder(content,'//*[@id="tw-target-text"]/*')
|
302 |
if trgt_lang == lang:
|
303 |
translated = trgt_text
|
304 |
-
ret = re.sub(f'[{
|
305 |
print(ret)
|
306 |
return ret
|
307 |
|
|
|
6 |
import logging
|
7 |
import re
|
8 |
import random
|
9 |
+
from string import ascii_letters, digits, punctuation
|
10 |
import requests
|
11 |
import sys
|
12 |
import warnings
|
|
|
18 |
|
19 |
# external
|
20 |
|
|
|
21 |
import torch
|
22 |
import gradio as gr
|
23 |
from numpy import asarray as array
|
24 |
from lxml.html import fromstring
|
|
|
|
|
25 |
from diffusers.utils import export_to_gif, load_image
|
|
|
26 |
from huggingface_hub import hf_hub_download
|
27 |
from safetensors.torch import load_file, save_file
|
28 |
from diffusers import DiffusionPipeline, AnimateDiffPipeline, MotionAdapter, EulerDiscreteScheduler, DDIMScheduler, StableDiffusionXLPipeline, UNet2DConditionModel, AutoencoderKL, UNet3DConditionModel
|
|
|
297 |
trgt_text = xpath_finder(content,'//*[@id="tw-target-text"]/*')
|
298 |
if trgt_lang == lang:
|
299 |
translated = trgt_text
|
300 |
+
ret = re.sub(f'[{punctuation}]', '', re.sub('[\s+]', ' ', translated)).lower().strip()
|
301 |
print(ret)
|
302 |
return ret
|
303 |
|