Update app.py
Browse files
app.py
CHANGED
|
@@ -1,20 +1,27 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
from transformers import pipeline
|
|
|
|
| 3 |
|
|
|
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
| 12 |
|
|
|
|
|
|
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
| 16 |
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
gr.Interface(fn=image_upscaler, inputs=input_image, outputs=output_image, title=title, description=description).launch()
|
|
|
|
|
|
|
| 1 |
from transformers import pipeline
|
| 2 |
+
from flask import Flask, request, jsonify
|
| 3 |
|
| 4 |
+
app = Flask(__name__)
|
| 5 |
|
| 6 |
+
# Create the pipeline for image upscaling
|
| 7 |
+
upscaler = pipeline("image-upscaling", model="deepset/electricity-converter-0036")
|
| 8 |
|
| 9 |
+
# Define the route for the home page
|
| 10 |
+
@app.route('/')
|
| 11 |
+
def home():
|
| 12 |
+
return 'Image Upscaling App'
|
| 13 |
|
| 14 |
+
# Define the route for the image upscaling
|
| 15 |
+
@app.route('/upscale', methods=['POST'])
|
| 16 |
+
def upscale():
|
| 17 |
+
# Get the uploaded image
|
| 18 |
+
file = request.files['file']
|
| 19 |
|
| 20 |
+
# Upscale the image
|
| 21 |
+
output = upscaler(file)
|
| 22 |
|
| 23 |
+
# Return the upscaled image
|
| 24 |
+
return jsonify({'image': output})
|
| 25 |
|
| 26 |
+
if __name__ == '__main__':
|
| 27 |
+
app.run()
|
|
|
|
|
|