Spaces:
Sleeping
Sleeping
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() |