om-app commited on
Commit
5e43fe5
·
1 Parent(s): 78a5b54

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -12
app.py CHANGED
@@ -1,20 +1,27 @@
1
- import gradio as gr
2
  from transformers import pipeline
 
3
 
 
4
 
5
- model_name = "joeddav/xlnet-base-cased"
6
- waifu2x = pipeline("image-upscaling", model=model_name)
7
 
 
 
 
 
8
 
9
- def image_upscaler(input_image):
10
- output_image = waifu2x(input_image)[0]['generated']
11
- return output_image
 
 
12
 
 
 
13
 
14
- input_image = gr.inputs.Image(label="Input Image")
15
- output_image = gr.outputs.Image(label="Enlarged Image", type="numpy")
16
 
17
- title = "Waifu2x Image Upscaler"
18
- description = "This app uses the Hugging Face transformers library to upscale images using the Waifu2x model."
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()