Spaces:
Runtime error
Runtime error
Update Dockerfile
Browse files- Dockerfile +32 -123
Dockerfile
CHANGED
|
@@ -1,127 +1,36 @@
|
|
| 1 |
-
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
# provided username and password. Do not set these in your Dockerfile, as they
|
| 17 |
-
# globally visible on a public space.
|
| 18 |
-
#
|
| 19 |
-
# LABEL_STUDIO_USERNAME
|
| 20 |
-
# LABEL_STUDIO_PASSWORD
|
| 21 |
-
#
|
| 22 |
-
# You will need to provide new users with an invitation link to join the space.
|
| 23 |
-
#
|
| 24 |
-
################################################################################
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
# ------------------------------------------------------------------------
|
| 30 |
-
#
|
| 31 |
-
# By default this space stores all project configuration and data annotations
|
| 32 |
-
# in local storage with sqlite. If the space is reset, all configuration and
|
| 33 |
-
# annotation data in the space will be lost. You can enable configuration
|
| 34 |
-
# persistence through one of two methods:
|
| 35 |
-
#
|
| 36 |
-
# 1) Enabling Hugging Face Persistent Storage for saving project and annotation
|
| 37 |
-
# settings, as well as local task storage.
|
| 38 |
-
# 2) Connecting an external Postgres database for saving project and annotation
|
| 39 |
-
# settings, and cloud by connecting cloud storage for tasks.
|
| 40 |
-
#
|
| 41 |
-
################################################################################
|
| 42 |
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
# ENV STORAGE_PERSISTENCE=1
|
| 55 |
-
#
|
| 56 |
-
# Your space will restart. NOTE: if you have existing settings and data,
|
| 57 |
-
# they will be lost in this first restart. Data and setting will only be
|
| 58 |
-
# preserved on subsequent restarts of the space.
|
| 59 |
-
#
|
| 60 |
-
################################################################################
|
| 61 |
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
# -----------------------------------------------------
|
| 66 |
-
#
|
| 67 |
-
# Set the following secret variables to match your own hosted instance of
|
| 68 |
-
# Postgres. We strongly recommend setting these as secrets to prevent leaking
|
| 69 |
-
# information about your database service to the public in your spaces
|
| 70 |
-
# definition.
|
| 71 |
-
#
|
| 72 |
-
# ENV DJANGO_DB=default
|
| 73 |
-
# ENV POSTGRE_NAME=<postgres_name>
|
| 74 |
-
# ENV POSTGRE_PORT=<db_port>
|
| 75 |
-
# ENV POSTGRE_USER=<postgres_user>
|
| 76 |
-
# ENV POSTGRE_PASSWORD=<password>
|
| 77 |
-
# ENV POSTGRE_PORT=<db_port>
|
| 78 |
-
# ENV POSTGRE_HOST=<db_host>
|
| 79 |
-
#
|
| 80 |
-
# Uncomment the following line or set the following Space variable to remove
|
| 81 |
-
# the warning about ephemeral storage
|
| 82 |
-
#
|
| 83 |
-
# ENV STORAGE_PERSISTENCE=1
|
| 84 |
-
#
|
| 85 |
-
# Note that you will need to connect cloud storage to host data items that you
|
| 86 |
-
# want to annotate, as local storage will not be preserved across a space reset.
|
| 87 |
-
#
|
| 88 |
-
#
|
| 89 |
-
# How to Enable Cloud Storage
|
| 90 |
-
# ---------------------------
|
| 91 |
-
# By default the only data storage enabled for this space is local. In the case
|
| 92 |
-
# of a space reset, all data will be lost. To enable permanent storage, you
|
| 93 |
-
# must enable a cloud storage connector. We also strongly recommend enabling
|
| 94 |
-
# configuration persistence to preserve project data, annotations, and user
|
| 95 |
-
# settings. Choose the appropriate cloud connector and configure the secrets
|
| 96 |
-
# for it.
|
| 97 |
-
#
|
| 98 |
-
# Amazon S3
|
| 99 |
-
# =========
|
| 100 |
-
# STORAGE_TYPE=s3
|
| 101 |
-
# STORAGE_AWS_ACCESS_KEY_ID="<YOUR_ACCESS_KEY_ID>"
|
| 102 |
-
# STORAGE_AWS_SECRET_ACCESS_KEY="<YOUR_SECRET_ACCESS_KEY>"
|
| 103 |
-
# STORAGE_AWS_BUCKET_NAME="<YOUR_BUCKET_NAME>"
|
| 104 |
-
# STORAGE_AWS_REGION_NAME="<YOUR_BUCKET_REGION>"
|
| 105 |
-
# STORAGE_AWS_FOLDER=""
|
| 106 |
-
#
|
| 107 |
-
# Google Cloud Storage
|
| 108 |
-
# ====================
|
| 109 |
-
#
|
| 110 |
-
# STORAGE_TYPE=gcs
|
| 111 |
-
# STORAGE_GCS_BUCKET_NAME="<YOUR_BUCKET_NAME>"
|
| 112 |
-
# STORAGE_GCS_PROJECT_ID="<YOUR_PROJECT_ID>"
|
| 113 |
-
# STORAGE_GCS_FOLDER=""
|
| 114 |
-
# GOOGLE_APPLICATION_CREDENTIALS="/opt/heartex/secrets/key.json"
|
| 115 |
-
#
|
| 116 |
-
# Azure Blob Storage
|
| 117 |
-
# ==================
|
| 118 |
-
#
|
| 119 |
-
# STORAGE_TYPE=azure
|
| 120 |
-
# STORAGE_AZURE_ACCOUNT_NAME="<YOUR_STORAGE_ACCOUNT>"
|
| 121 |
-
# STORAGE_AZURE_ACCOUNT_KEY="<YOUR_STORAGE_KEY>"
|
| 122 |
-
# STORAGE_AZURE_CONTAINER_NAME="<YOUR_CONTAINER_NAME>"
|
| 123 |
-
# STORAGE_AZURE_FOLDER=""
|
| 124 |
-
#
|
| 125 |
-
################################################################################
|
| 126 |
-
|
| 127 |
-
CMD exec label-studio --host=$SPACE_HOST
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import subprocess
|
| 3 |
|
| 4 |
+
def deblur_image(input_image_path, angle_model_path, length_model_path):
|
| 5 |
+
command = [
|
| 6 |
+
"python",
|
| 7 |
+
"deblur_img.py",
|
| 8 |
+
"--image",
|
| 9 |
+
input_image_path,
|
| 10 |
+
"--angle_model",
|
| 11 |
+
angle_model_path,
|
| 12 |
+
"--length_model",
|
| 13 |
+
length_model_path
|
| 14 |
+
]
|
| 15 |
+
result = subprocess.run(command, capture_output=True, text=True)
|
| 16 |
+
return result.stdout
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
+
def deblur_and_display(input_image, angle_model_path, length_model_path):
|
| 19 |
+
output = deblur_image(input_image.name, angle_model_path, length_model_path)
|
| 20 |
+
return output
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
+
iface = gr.Interface(
|
| 23 |
+
fn=deblur_and_display,
|
| 24 |
+
inputs=[
|
| 25 |
+
gr.inputs.Image(label="Upload Image"),
|
| 26 |
+
gr.inputs.Textbox(label="Angle Model Path", default="/app/pretrained_models/angle_model.hdf5"),
|
| 27 |
+
gr.inputs.Textbox(label="Length Model Path", default="/app/pretrained_models/length_model.hdf5")
|
| 28 |
+
],
|
| 29 |
+
outputs="text",
|
| 30 |
+
title="Image Deblurring App",
|
| 31 |
+
description="Upload an image to deblur it."
|
| 32 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
+
if __name__ == "__main__":
|
| 35 |
+
iface.launch()
|
| 36 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|