Skip to content

Commit

Permalink
proyecto-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
lriveraBanco committed Apr 26, 2024
1 parent cec28b8 commit 0c77229
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 85 deletions.
30 changes: 24 additions & 6 deletions roop/Frontend/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,34 @@ def upload():
img_data = img_data.replace('data:image/png;base64,', '')
img_bytes = base64.b64decode(img_data)

# Incrementar el contador de capturas
captureCounter += 1
# Obtener el número del botón que fue presionado
button_number = int(request.form['button_number'])

# Guardar la imagen en una carpeta específica con el contador como nombre
img_name = f"captura_{captureCounter}.png"
img_path = os.path.join('roop/', img_name)
# Guardar la imagen en una carpeta específica con el nombre del personaje
character_name = {
1: 'Hulk',
2: 'Black Widow',
3: 'Captain America',
4: 'Captain Marvel',
5: 'Hawkeye',
6: 'Scarlet Witch'
}.get(button_number, 'Unknown')

img_name = f"{character_name}.png"
img_path = os.path.join('roop/images/', img_name)
with open(img_path, 'wb') as img_file:
img_file.write(img_bytes)

# Ejecutar el comando para procesar la imagen
if character_name == 'Unknown':
return redirect(url_for('index'))

# Procesar la imagen con el comando específico
command = f"%cd '/content/roop' && python run.py -s '{character_name}.png' -t 'brad org.mp4' -o 'face_restored_video3.mp4' --keep-frames --keep-fps --temp-frame-quality 1 --output-video-quality 1 --execution-provider cuda --frame-processor face_swapper face_enhancer"
os.system(command)

return redirect(url_for('index'))


if __name__ == '__main__':
app.run(debug=True)
app.run(debug=True)
Loading

0 comments on commit 0c77229

Please sign in to comment.