File size: 1,612 Bytes
7312ff0
6d102f7
0246891
7312ff0
0246891
 
 
 
 
 
2f0282a
0246891
d162e63
2f0282a
 
0246891
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2f0282a
ce53d19
0246891
 
 
 
2f0282a
 
0246891
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import requests
import bs4
import gradio as gr
from bs4 import BeautifulSoup

def run_lora(prompt):
    page = requests.get("https://www.google.dz/search?q="+prompt)
    soup = BeautifulSoup(page.content)
    import re
    links = soup.findAll("a")
    mLink=""
    for link in  soup.find_all("a",href=re.compile("(?<=/url\?q=)(htt.*://.*)")):
        print (re.split(":(?=http)",link["href"].replace("/url?q=","")))
        mLink+=re.split(":(?=http)",link["href"].replace("/url?q=",""))
    return mLink
css = '''
#gen_btn{height: 100%}
#title{text-align: center}
#title h1{font-size: 3em; display:inline-flex; align-items:center}
#title img{width: 100px; margin-right: 0.5em}
#gallery .grid-wrap{height: 10vh}
'''
with gr.Blocks(theme=gr.themes.Soft(), css=css) as app:
    title = gr.HTML(
        """<h1><img src="https://huggingface.co/spaces/multimodalart/flux-lora-the-explorer/resolve/main/flux_lora.png" alt="LoRA"> FLUX LoRA the Explorer</h1>""",
        elem_id="title",
    )
    selected_index = gr.State(None)
    with gr.Row():
        with gr.Column(scale=3):
            prompt = gr.Textbox(label="Prompt", lines=1, placeholder="Type a prompt after selecting a LoRA")
        with gr.Column(scale=1, elem_id="gen_column"):
            generate_button = gr.Button("Generate", variant="primary", elem_id="gen_btn")
            translated_textbox = gr.Textbox(lines=5, placeholder="", label="Translated Text")
   

    gr.on(
        triggers=[generate_button.click, prompt.submit],
        fn=run_lora,
        inputs=[prompt],
        outputs=[translated_textbox]
    )

app.queue()
app.launch()