Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dksony8 patch 1 #866

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
pip install flask
pip install flask-cors

from flask import Flask, request, jsonify, send_file
import os
from realesrgan import RealESRGAN

app = Flask(__name__)

# Initialize Real-ESRGAN model (ensure model weights are downloaded)
model = RealESRGAN('RealESRGAN_x4plus')

@app.route('/enhance', methods=['POST'])
def enhance_image():
try:
# Save the uploaded image
file = request.files['image']
input_path = 'input.jpg'
file.save(input_path)

# Enhance the image using Real-ESRGAN
output_path = 'output.jpg'
model.enhance(input_path, output_path)

# Return the enhanced image
return send_file(output_path, mimetype='image/jpeg')

except Exception as e:
return jsonify({'error': str(e)}), 500

if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000)
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ Pillow
torch>=1.7
torchvision
tqdm
flask
gunicorn
flask-cors