File size: 1,738 Bytes
7405474
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import streamlit as st
import os
from PIL import Image
from chainguard.blockchain_logger import BlockchainLogger

# Initialize Blockchain Logger
blockchain_logger = BlockchainLogger()


def log_metadata(file_name, tags, album):
    """Log photo metadata to Chagu blockchain."""
    metadata = {
        "file_name": file_name,
        "tags": tags,
        "album": album
    }
    block_details = blockchain_logger.log_data(metadata)
    return block_details


# Streamlit App Layout
st.title("Memora: Photo & Video Uploader")
st.subheader("Securely upload and organize your memories")

# File Upload
uploaded_files = st.file_uploader(
    "Upload your photos or videos", accept_multiple_files=True, type=['jpg', 'jpeg', 'png', 'mp4', 'avi']
)

if uploaded_files:
    for uploaded_file in uploaded_files:
        # Display uploaded file
        st.write(f"File Name: {uploaded_file.name}")
        if uploaded_file.type.startswith('image'):
            image = Image.open(uploaded_file)
            st.image(image, caption=uploaded_file.name, use_column_width=True)

        # Metadata Input
        album = st.text_input(f"Album for {uploaded_file.name}", value="Default Album")
        tags = st.text_input(f"Tags for {uploaded_file.name} (comma-separated)", value="")

        # Log Metadata
        if st.button(f"Log Metadata for {uploaded_file.name}"):
            metadata = log_metadata(uploaded_file.name, tags.split(','), album)
            st.write(f"Metadata logged successfully! Block Details: {metadata}")

# Display Blockchain Validation
if st.button("Validate Blockchain Integrity"):
    is_valid = blockchain_logger.is_blockchain_valid()
    st.write("Blockchain Integrity:", "Valid βœ…" if is_valid else "Invalid ❌")