Spaces:
Sleeping
Sleeping
File size: 3,364 Bytes
eef6aa0 9619c6f eef6aa0 9619c6f eef6aa0 9619c6f eef6aa0 ca60730 d2c9d91 eef6aa0 165dbe4 eef6aa0 9619c6f |
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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
import os
import requests
import gradio as gr
url = os.environ["URL_NODE"]
def detect_image(image):
print("image: ", image)
files = {"picture": open(image, "rb")}
resp = requests.post(url,
files=files,
verify=False)
resp = resp.json()
gen_url = resp["data"]["answer"]
return gen_url
def read_content(file_path):
with open(file_path, 'r', encoding='utf-8') as f:
content = f.read()
return content
example_images = [
os.path.join(os.path.dirname(__file__), "examples/00.jpg"),
os.path.join(os.path.dirname(__file__), "examples/01.jpg"),
os.path.join(os.path.dirname(__file__), "examples/02.jpg"),
os.path.join(os.path.dirname(__file__), "examples/03.jpg"),
os.path.join(os.path.dirname(__file__), "examples/04.jpg"),
os.path.join(os.path.dirname(__file__), "examples/05.jpg"),
os.path.join(os.path.dirname(__file__), "examples/06.png")
]
default_image = example_images[0]
css = """
.gradio-container {background-image: url('file=./background.jpg'); background-size:cover; background-repeat: no-repeat;}
"""
# warm up
# detect_image()
with gr.Blocks(css=css) as demo:
gr.HTML(read_content("./header.html"))
gr.Markdown("# MindSpore Wuhan.LuoJiaNET")
gr.Markdown(
"`Wuhan.LuoJiaNET` is the first domestic autonomous and controllable machine learning framework for remote sensing in the field of remote sensing,"
" jointly developed by` Wuhan University` and `Huawei's Ascend AI team`, which has the characteristics of large image size,"
" multiple data channels, and large scale variation of remote sensing data."
" It is compatible with existing deep learning frameworks and provides a user-friendly,"
" drag-and-drop interactive network structure to build an interface."
" It can shield the differences between different hardware devices and manage a diversified remote sensing image sample library,"
" LuoJiaSET, to achieve efficient storage and management of remote multi-source sensing image samples."
)
with gr.Tab("目标识别 (Object Detection)"):
with gr.Row():
image_input = gr.Image(
type="filepath",
value=default_image
)
image_output = gr.Image(
type="filepath",
interactive=False
)
gr.Examples(
examples=example_images,
inputs=image_input,
)
image_button = gr.Button("Detect")
with gr.Accordion("Open for More!"):
gr.Markdown(
"- If you want to know more about the foundation models of MindSpore, please visit "
"[The Foundation Models Platform for Mindspore](https://xihe.mindspore.cn/)"
)
gr.Markdown(
"- If you want to know more about Wuhan.LuoJiaNET, please visit "
"[Wuhan.LuoJiaNET](https://github.com/WHULuoJiaTeam/luojianet)")
gr.Markdown(
"- Try [Wukong-LuojiaNET model on the Foundation Models Platform for Mindspore]"
"(https://xihe.mindspore.cn/modelzoo/luojia)")
image_button.click(detect_image,
inputs=[image_input],
outputs=[image_output])
demo.queue(concurrency_count=5)
demo.launch(enable_queue=True) |