import streamlit as st from transformers import pipeline from rembg import remove from PIL import Image from io import BytesIO import base64 from transformers import GPT2LMHeadModel, GPT2Tokenizer from transformers import set_seed import random import nltk from nltk.corpus import stopwords from nltk.tokenize import sent_tokenize, word_tokenize from nltk.probability import FreqDist from nltk import download # Download NLTK data (if not already downloaded) download('punkt') download('stopwords') # Set seed for reproducibility set_seed(42) st.set_page_config(layout="wide", page_title="Image Classification App") st.write("## Image Food Classification App") st.sidebar.write("## Upload and download :gear:") image_classifier = pipeline("image-classification", model="mjsp/sweet") recipe_model = GPT2LMHeadModel.from_pretrained("gpt2") recipe_tokenizer = GPT2Tokenizer.from_pretrained("gpt2") MAX_FILE_SIZE = 5 * 1024 * 1024 # 5MB def convert_image(img): buf = BytesIO() img.save(buf, format="PNG") byte_im = buf.getvalue() return byte_im def fix_image(upload): image = Image.open(upload) col1.write("Original Image :camera:") col1.image(image) fixed = remove(image) col2.write("Fixed Image :wrench:") col2.image(fixed) st.sidebar.markdown("\n") st.sidebar.download_button("Download fixed image", convert_image(fixed), "fixed.png", "image/png") def generate_summary(recipe): # Tokenize the text into words and sentences sentences = sent_tokenize(recipe) words = word_tokenize(recipe) # Remove stopwords stop_words = set(stopwords.words('english')) filtered_words = [word for word in words if word.lower() not in stop_words] # Calculate word frequency fdist = FreqDist(filtered_words) # Sort words by frequency and get the most common most_common_words = [word for word, freq in fdist.most_common(10)] # Generate a summary by selecting sentences that contain the most common words summary = [sentence for sentence in sentences if any(word in sentence for word in most_common_words)] return ' '.join(summary) # Your dataset of titles, ingredients, and recipes dataset =[ { "title": "Gulab Jamun", "ingredients": [ "1 cup milk powder", "2 tbsp all-purpose flour", "1/4 tsp baking soda", "2 tbsp ghee", "1/4 cup milk", "1/4 tsp cardamom powder", "A pinch of saffron strands", "For Sugar Syrup:", "1 cup sugar", "1/2 cup water", "A few drops of rose water" ], "recipe": "Gulab Jamun Recipe:\n" "1. In a mixing bowl, combine milk powder, all-purpose flour, baking soda, ghee, milk, and cardamom powder.\n" "2. Knead the mixture into a soft dough. If it's too dry, add a little more milk.\n" "3. Shape the dough into small balls.\n" "4. Heat ghee in a pan and deep fry the dough balls until golden brown.\n" "5. In a separate saucepan, make sugar syrup by boiling sugar and water until it thickens.\n" "6. Add a few drops of rose water and saffron strands to the sugar syrup.\n" "7. Soak the fried gulab jamun in the sugar syrup for a few hours until they absorb the syrup.\n" "8. Serve warm or chilled. Enjoy!" }, { "title": "Jalebi", "ingredients": [ "1 cup all-purpose flour", "1/4 cup yogurt", "A pinch of baking soda", "1/4 tsp cardamom powder", "A few saffron strands", "1 cup sugar", "1/2 cup water", "Ghee or oil for frying" ], "recipe": "Jalebi Recipe:\n" "1. In a mixing bowl, combine all-purpose flour, yogurt, baking soda, and water to form a smooth batter.\n" "2. Allow the batter to ferment for a few hours or overnight.\n" "3. Make a sugar syrup by boiling sugar and water until it forms a one-string consistency.\n" "4. Add cardamom powder and saffron strands to the sugar syrup.\n" "5. Heat ghee or oil in a pan for frying.\n" "6. Pour the batter into a squeeze bottle or a piping bag.\n" "7. Squeeze the batter into hot oil in a spiral shape and deep fry until golden.\n" "8. Drain the jalebi and soak them in the sugar syrup for a few minutes.\n" "9. Serve the sweet and syrupy jalebi." }, { "title": "Rasgulla", "ingredients": [ "1 liter full-fat milk", "1/4 cup lemon juice", "1 cup sugar", "4 cups water", "A few drops of rose water" ], "recipe": "Rasgulla Recipe:\n" "1. Boil the milk in a heavy-bottomed pan and add lemon juice to curdle the milk.\n" "2. Drain the whey using a muslin cloth, leaving behind the chhena (paneer).\n" "3. Knead the chhena until it's smooth and make small balls.\n" "4. In a separate pot, combine sugar and water and bring it to a boil to make sugar syrup.\n" "5. Gently add the chhena balls to the boiling sugar syrup.\n" "6. Cover and cook for about 20-25 minutes until the rasgullas double in size.\n" "7. Add a few drops of rose water for flavor.\n" "8. Let the rasgullas cool and refrigerate before serving. Enjoy!" }, { "title": "Adhirasam", "ingredients": [ "1 cup rice flour", "1/4 cup jaggery", "1/4 cup ghee", "A pinch of cardamom powder", "A pinch of dry ginger powder", "Oil for deep frying" ], "recipe": "Adhirasam Recipe:\n" "1. Dissolve jaggery in a little water and strain to remove impurities.\n" "2. Mix rice flour, jaggery syrup, ghee, cardamom powder, and dry ginger powder to form a dough.\n" "3. Shape the dough into flat round adhirasams.\n" "4. Heat oil and deep fry the adhirasams until they turn golden brown.\n" "5. Drain and enjoy the sweet adhirasams." }, { "title": "Anarsa", "ingredients": [ "1 cup rice", "1/2 cup powdered sugar", "1/4 cup poppy seeds", "Ghee for deep frying", ], "recipe": "Anarsa Recipe:\n" "1. Soak rice overnight and grind it to a fine paste.\n" "2. Mix the rice paste with powdered sugar and form a smooth dough.\n" "3. Roll out small discs and coat them with poppy seeds.\n" "4. Heat ghee and deep fry the anarsas until they are golden brown.\n" "5. Drain and enjoy these crispy sweets." }, { "title": "Anjeer Barfi", "ingredients": [ "1 cup dried figs (anjeer)", "1/2 cup condensed milk", "1/4 cup milk", "2 tbsp ghee", ], "recipe": "Anjeer Barfi Recipe:\n" "1. Soak dried figs in warm water until soft, then grind them to a smooth paste.\n" "2. Heat ghee in a pan and add the fig paste, condensed milk, and milk.\n" "3. Cook until the mixture thickens and leaves the sides of the pan.\n" "4. Spread it in a greased plate, let it set, and cut into barfi squares.\n" "5. Enjoy the delicious anjeer barfi." }, { "title": "Badam Burfi", "ingredients": [ "1 cup almonds (badam)", "1/2 cup sugar", "1/4 cup water", "A pinch of cardamom powder", "Ghee for greasing", ], "recipe": "Badam Burfi Recipe:\n" "1. Soak almonds in hot water, remove the skin, and grind them to a fine paste.\n" "2. Make sugar syrup by boiling sugar and water until it reaches one-string consistency.\n" "3. Add the almond paste and cook until it thickens.\n" "4. Add cardamom powder and mix well.\n" "5. Spread the mixture in a greased plate, let it set, and cut into burfi squares.\n" "6. Enjoy the sweet and nutty badam burfi." }, { "title": "Bal Mithai", "ingredients": [ "1 cup khoya", "1/2 cup powdered sugar", "2 tbsp cocoa powder", "2 tbsp milk", "2 tbsp ghee", "A pinch of cardamom powder", ], "recipe": "Bal Mithai Recipe:\n" "1. Heat ghee in a pan and add khoya. Cook until it's light brown.\n" "2. Add powdered sugar, cocoa powder, and milk. Cook until it thickens.\n" "3. Add cardamom powder and mix well.\n" "4. Spread it in a greased plate, let it set, and cut into squares.\n" "5. Enjoy the chocolaty Bal Mithai." }, { "title": "Balushahi", "ingredients": [ "1 cup all-purpose flour", "1/4 cup yogurt", "1/4 cup ghee", "1/4 tsp baking soda", "1/4 cup water", "For Sugar Syrup:", "1 cup sugar", "1/2 cup water", "A pinch of cardamom powder", ], "recipe": "Balushahi Recipe:\n" "1. In a mixing bowl, combine all-purpose flour, yogurt, ghee, baking soda, and water to form a smooth dough.\n" "2. Cover and let the dough rest for 30 minutes.\n" "3. Make small discs and create a dent in the center.\n" "4. Heat ghee and deep fry the balushahi until golden brown.\n" "5. Make sugar syrup by boiling sugar, water, and cardamom powder until it thickens.\n" "6. Dip the balushahi in the sugar syrup and let it soak for a while.\n" "7. Enjoy the sweet and flaky balushahi." }, { "title": "Basundi", "ingredients": [ "1 liter full-fat milk", "1/2 cup sugar", "1/4 cup chopped nuts (almonds, pistachios)", "A pinch of saffron strands", "1/4 tsp cardamom powder", ], "recipe": "Basundi Recipe:\n" "1. Boil milk in a heavy-bottomed pan and simmer until it reduces to half.\n" "2. Add sugar, saffron strands, cardamom powder, and chopped nuts.\n" "3. Cook until it thickens and has a creamy consistency.\n" "4. Chill and serve the delicious basundi." }, { "title": "Besan Laddu", "ingredients": [ "2 cups besan (gram flour)", "1 cup powdered sugar", "1/2 cup ghee", "A pinch of cardamom powder", "Chopped nuts for garnish", ], "recipe": "Besan Laddu Recipe:\n" "1. Heat ghee in a pan and roast besan on low heat until it turns aromatic and golden brown.\n" "2. Let it cool slightly and add powdered sugar and cardamom powder.\n" "3. Mix well and shape into laddus. Garnish with chopped nuts.\n" "4. Enjoy the sweet and nutty besan laddu." }, { "title": "Bobbatlu", "ingredients": [ "1 cup chana dal", "1 cup jaggery", "1 cup maida (all-purpose flour)", "1/4 cup ghee", "A pinch of turmeric powder", "A pinch of cardamom powder" ], "recipe": "Bobbatlu Recipe:\n" "1. Cook chana dal until it's soft and can be mashed easily.\n" "2. Drain excess water and grind the cooked dal with jaggery into a smooth paste.\n" "3. Heat ghee in a pan, add the dal-jaggery mixture, and cook until it thickens.\n" "4. Add turmeric and cardamom powder, mix well, and let it cool.\n" "5. Make small balls of the mixture and set them aside.\n" "6. In a separate bowl, prepare a soft dough with maida and water.\n" "7. Take a small portion of the dough, flatten it, and place a dal-jaggery ball in the center.\n" "8. Seal the edges and flatten the stuffed dough into a circle.\n" "9. Heat a griddle and cook the bobbatlu until they are golden and cooked on both sides.\n" "10. Serve the delicious bobbatlu." }, { "title": "Boondi", "ingredients": [ "2 cups besan (gram flour)", "A pinch of baking soda", "1/4 tsp cardamom powder", "A pinch of saffron strands", "Oil for frying", "For Sugar Syrup:", "1 cup sugar", "1/2 cup water" ], "recipe": "Boondi Recipe:\n" "1. Prepare a batter with besan, baking soda, and water. The consistency should be thin.\n" "2. Heat oil in a pan for frying.\n" "3. Hold a perforated ladle or slotted spoon over the hot oil.\n" "4. Pour a ladleful of batter onto the ladle, and tiny droplets (boondi) will fall into the oil.\n" "5. Fry until they are crisp but not brown.\n" "6. Make sugar syrup by boiling sugar and water until it reaches a one-string consistency.\n" "7. Add cardamom powder and saffron strands to the sugar syrup.\n" "8. Immerse the boondi in the sugar syrup, let it soak, and serve." }, { "title": "Boondi Ladoo", "ingredients": [ "2 cups boondi (prepared as per the previous recipe)", "1/2 cup powdered sugar", "1/4 cup chopped nuts (cashews, almonds)", "A pinch of cardamom powder", "2-3 tbsp ghee" ], "recipe": "Boondi Ladoo Recipe:\n" "1. Take the prepared boondi and add powdered sugar, cardamom powder, and chopped nuts.\n" "2. Mix well and ensure that the sugar is evenly coated.\n" "3. Heat ghee in a small pan and add it to the mixture for binding.\n" "4. Shape the mixture into small round ladoos while it's still warm.\n" "5. Let them cool and solidify before serving." }, { "title": "Cham Cham", "ingredients": [ "1 liter milk", "1/2 cup lemon juice", "1/4 cup sugar", "A pinch of cardamom powder", "2-3 drops of rose water", "A few pistachios for garnish" ], "recipe": "Cham Cham Recipe:\n" "1. Boil the milk and add lemon juice to curdle it.\n" "2. Drain the whey using a muslin cloth and collect the chhena (paneer).\n" "3. Knead the chhena until smooth and divide it into small cylindrical shapes (cham cham).\n" "4. Boil sugar and water to make sugar syrup. Add cardamom powder and rose water.\n" "5. Boil the cham cham in the sugar syrup for 20-25 minutes until they expand in size.\n" "6. Let them cool, garnish with pistachios, and serve." }, { "title": "Chena Murki", "ingredients": [ "2 cups chhena (paneer)", "1 cup sugar", "1/4 cup water", "A pinch of cardamom powder", "A few strands of saffron", "2-3 drops of rose water" ], "recipe": "Chena Murki Recipe:\n" "1. Take chhena and shape it into small, flat rectangles or any desired shape.\n" "2. Prepare sugar syrup by boiling sugar and water until it reaches a one-string consistency.\n" "3. Add cardamom powder, saffron strands, and rose water to the syrup.\n" "4. Immerse the chena pieces in the syrup, ensuring they are well coated.\n" "5. Let them cool and absorb the flavors before serving." }, { "title": "Chenna Poda", "ingredients": [ "2 cups chhena (paneer)", "1 cup sugar", "2-3 tbsp semolina", "1/4 cup ghee", "A pinch of cardamom powder", "A few raisins and cashews for garnish" ], "recipe": "Chenna Poda Recipe:\n" "1. Take chhena and add sugar, semolina, ghee, and cardamom powder.\n" "2. Mix well and let it rest for a few hours.\n" "3. Preheat the oven to 180°C (350°F).\n" "4. Grease a cake tin and transfer the chenna mixture to it.\n" "5. Garnish with raisins and cashews.\n" "6. Bake for about 45-50 minutes until it's browned and firm.\n" "7. Let it cool, slice, and enjoy the chenna poda." }, { "title": "Chikki", "ingredients": [ "1 cup peanuts", "1/2 cup jaggery", "1/4 cup ghee", "A pinch of cardamom powder" ], "recipe": "Chikki Recipe:\n" "1. Dry roast the peanuts until they are crisp and remove the skins.\n" "2. Crush the peanuts coarsely.\n" "3. Heat ghee in a pan and add jaggery. Cook until it melts and forms a one-string consistency.\n" "4. Add the crushed peanuts and cardamom powder to the melted jaggery.\n" "5. Mix quickly and transfer it to a greased plate. Flatten it with a greased rolling pin.\n" "6. Let it cool, break it into pieces, and enjoy the chikki." }, { "title": "Chiroti", "ingredients": [ "1 cup maida (all-purpose flour)", "1/4 cup ghee", "A pinch of salt", "Oil for deep frying", "For Sugar Syrup:", "1 cup sugar", "1/2 cup water" ], "recipe": "Chiroti Recipe:\n" "1. Prepare a soft and smooth dough with maida, ghee, and a pinch of salt.\n" "2. Divide the dough into small portions and roll them into thin sheets.\n" "3. Fold the sheets into layers and roll them again to form a spiral shape.\n" "4. Heat oil in a pan and deep fry the chiroti until they are golden and crisp.\n" "5. Make sugar syrup by boiling sugar and water until it reaches a one-string consistency.\n" "6. Immerse the fried chiroti in the sugar syrup for a few minutes.\n" "7. Serve the sweet and flaky chiroti." }, { "title": "Coconut Ladoo", "ingredients": [ "2 cups desiccated coconut", "1 cup condensed milk", "1/4 cup milk", "1/4 tsp cardamom powder", "A few cashews and raisins for garnish" ], "recipe": "Coconut Ladoo Recipe:\n" "1. Heat a pan and add desiccated coconut. Roast it until it's aromatic but not brown.\n" "2. Add condensed milk and milk. Mix well and cook until the mixture thickens.\n" "3. Add cardamom powder and mix.\n" "4. Let it cool slightly and shape it into small ladoos.\n" "5. Garnish with cashews and raisins.\n" "6. Let the ladoos cool completely before serving." }, { "title": "Dhondas", "ingredients": [ "1 cup semolina (rava)", "1/2 cup grated jaggery", "1/4 cup grated coconut", "1/4 cup milk", "A pinch of cardamom powder", "A pinch of nutmeg powder", "1/4 cup ghee", "1/4 tsp baking soda", "1/4 cup chopped nuts (cashews, almonds)" ], "recipe": "Dhondas Recipe:\n" "1. In a mixing bowl, combine semolina, grated jaggery, grated coconut, and milk.\n" "2. Mix well and let it rest for about 2 hours to allow the semolina to absorb the liquid.\n" "3. Add cardamom powder, nutmeg powder, ghee, and baking soda to the mixture.\n" "4. Mix in the chopped nuts.\n" "5. Transfer the batter to a greased pan and steam it for about 30-40 minutes until it's cooked.\n" "6. Let it cool, cut into pieces, and enjoy the dhondas." }, { "title": "Double ka Meetha", "ingredients": [ "4 slices of bread", "1/2 cup milk", "1/4 cup condensed milk", "A pinch of cardamom powder", "1/4 cup ghee", "2-3 tbsp sugar", "A few cashews and raisins" ], "recipe": "Double ka Meetha Recipe:\n" "1. Cut the bread slices into triangles or pieces of your choice.\n" "2. Heat ghee in a pan and fry the bread pieces until they are golden and crisp.\n" "3. In another pan, heat milk and add condensed milk and sugar.\n" "4. Let it simmer until it thickens and add cardamom powder.\n" "5. Pour the milk mixture over the fried bread pieces and let them soak it up.\n" "6. Garnish with cashews and raisins.\n" "7. Serve the delicious double ka meetha." }, { "title": "Dry Fruits Chikki", "ingredients": [ "1 cup mixed dry fruits (almonds, cashews, pistachios)", "1 cup jaggery", "1/4 cup ghee", "A pinch of cardamom powder" ], "recipe": "Dry Fruits Chikki Recipe:\n" "1. Dry roast the mixed dry fruits until they are crisp and remove the skins.\n" "2. Crush the dry fruits coarsely.\n" "3. Heat ghee in a pan and add jaggery. Cook until it melts and forms a one-string consistency.\n" "4. Add the crushed dry fruits and cardamom powder to the melted jaggery.\n" "5. Mix quickly and transfer it to a greased plate. Flatten it with a greased rolling pin.\n" "6. Let it cool, break it into pieces, and enjoy the dry fruits chikki." }, { "title": "Gajar ka Halwa", "ingredients": [ "2 cups grated carrots", "2 cups milk", "1/2 cup sugar", "1/4 cup ghee", "A pinch of cardamom powder", "A few cashews and raisins" ], "recipe": "Gajar ka Halwa Recipe:\n" "1. In a heavy-bottomed pan, heat ghee and add grated carrots. Cook until they are soft and aromatic.\n" "2. Add milk and simmer until the mixture thickens.\n" "3. Add sugar and cook until it dissolves and the halwa thickens further.\n" "4. Add cardamom powder and mix well.\n" "5. Garnish with cashews and raisins.\n" "6. Serve the warm and delightful gajar ka halwa." }, { "title": "Ghevar", "ingredients": [ "1 cup all-purpose flour", "1/4 cup ghee", "A pinch of cardamom powder", "A pinch of saffron strands", "2 cups sugar syrup", "Ghee for frying", "A few chopped nuts for garnish" ], "recipe": "Ghevar Recipe:\n" "1. In a mixing bowl, combine all-purpose flour and ghee to form a crumbly mixture.\n" "2. Gradually add water and knead the mixture into a smooth batter.\n" "3. Heat ghee in a wide, shallow pan with a hole in the center.\n" "4. Pour the batter through a perforated spoon into the hot ghee, forming a lacy pattern.\n" "5. Fry until it's crisp and golden.\n" "6. Soak the ghevar in saffron-infused sugar syrup for a few minutes.\n" "7. Garnish with chopped nuts and enjoy the delightful ghevar." }, { "title": "Gud Papdi", "ingredients": [ "1 cup whole wheat flour", "1/2 cup ghee", "1/2 cup jaggery", "A pinch of cardamom powder" ], "recipe": "Gud Papdi Recipe:\n" "1. In a heavy-bottomed pan, heat ghee and add whole wheat flour.\n" "2. Roast the flour until it's golden and aromatic.\n" "3. Add jaggery and cardamom powder. Mix well.\n" "4. Transfer the mixture to a greased plate and flatten it.\n" "5. Let it cool and set before cutting into papdi pieces." }, { "title": "Gudanna", "ingredients": [ "1 cup broken wheat (dalia)", "1/2 cup jaggery", "4 cups milk", "1/4 cup ghee", "A pinch of cardamom powder", "A few chopped nuts" ], "recipe": "Gudanna Recipe:\n" "1. Dry roast the broken wheat until it's aromatic and browned.\n" "2. Heat ghee in a pan and add the roasted broken wheat. Cook for a few minutes.\n" "3. Add milk and simmer until the broken wheat is soft and cooked.\n" "4. Add jaggery and cardamom powder. Mix well and cook until the gudanna thickens.\n" "5. Garnish with chopped nuts and serve the delicious gudanna." }, { "title": "Gujiya", "ingredients": [ "2 cups all-purpose flour", "1/4 cup ghee", "1/2 cup milk", "For Filling:", "1 cup khoya (mawa)", "1/2 cup powdered sugar", "1/4 cup chopped nuts (almonds, cashews, pistachios)", "A pinch of cardamom powder", "Oil for deep frying" ], "recipe": "Gujiya Recipe:\n" "1. Prepare a soft dough by combining all-purpose flour, ghee, and milk.\n" "2. Divide the dough into small portions and roll them into thin rounds.\n" "3. In a mixing bowl, combine khoya, powdered sugar, chopped nuts, and cardamom powder for the filling.\n" "4. Place a portion of the filling on one half of the dough round and fold it over to form a half-moon shape.\n" "5. Seal the edges by pressing or crimping.\n" "6. Heat oil in a pan and deep fry the gujiyas until they are golden brown.\n" "7. Drain and let them cool before serving the sweet gujiyas." }, { "title": "Halwa", "ingredients": [ "1 cup semolina (rava)", "1/2 cup ghee", "1 cup sugar", "2 cups water", "A pinch of cardamom powder", "A pinch of saffron strands", "A few chopped nuts (cashews, almonds)" ], "recipe": "Halwa Recipe:\n" "1. In a pan, heat ghee and add semolina. Roast until it's golden and aromatic.\n" "2. In a separate pot, combine sugar and water to make sugar syrup.\n" "3. Add the sugar syrup to the roasted semolina while stirring continuously.\n" "4. Add cardamom powder and saffron strands for flavor.\n" "5. Cook until the halwa thickens and leaves the sides of the pan.\n" "6. Garnish with chopped nuts and serve the delightful halwa." }, { "title": "Kaju Anjeer Roll", "ingredients": [ "1 cup cashews", "1/2 cup anjeer (figs)", "1/2 cup sugar", "1/4 cup ghee", "A pinch of cardamom powder", "A few chopped pistachios for garnish" ], "recipe": "Kaju Anjeer Roll Recipe:\n" "1. Grind cashews and anjeer to a smooth paste separately.\n" "2. Heat ghee in a pan and add the anjeer paste. Cook until it thickens.\n" "3. Add the cashew paste and continue to cook.\n" "4. Add sugar and cardamom powder. Mix well and cook until the mixture leaves the sides of the pan.\n" "5. Transfer the mixture to a greased plate, garnish with chopped pistachios, and let it cool before cutting into barfi pieces." }, { "title": "Kaju Katli", "ingredients": [ "1 cup cashews", "1/2 cup sugar", "1/4 cup water", "A pinch of cardamom powder", "A few silver leaf (varak) for garnish" ], "recipe": "Kaju Katli Recipe:\n" "1. Grind cashews to a fine powder.\n" "2. Make a sugar syrup by boiling sugar and water until it forms a one-string consistency.\n" "3. Add the cashew powder and cardamom powder to the sugar syrup. Mix well and cook until it thickens.\n" "4. Transfer the mixture to a greased plate, press with a flat spatula, and let it cool.\n" "5. Cut into diamond-shaped pieces and garnish with silver leaf (varak)." }, { "title": "Kala Jamun", "ingredients": [ "1 cup milk powder", "1/4 cup all-purpose flour", "1/4 cup khoya (mawa)", "A pinch of baking soda", "1/4 cup milk", "A few drops of rose water", "Ghee for frying", "For Sugar Syrup:", "1 cup sugar", "1/2 cup water", "A pinch of cardamom powder" ], "recipe": "Kala Jamun Recipe:\n" "1. In a mixing bowl, combine milk powder, all-purpose flour, khoya, baking soda, milk, and rose water.\n" "2. Knead the mixture into a soft dough. If it's too dry, add a little more milk.\n" "3. Shape the dough into small balls and deep fry them in ghee until they are dark brown (kala).\n" "4. Make sugar syrup by boiling sugar and water until it forms a one-string consistency. Add cardamom powder.\n" "5. Soak the fried kala jamun in the sugar syrup for a few hours until they absorb the syrup.\n" "6. Serve the delicious kala jamun." }, { "title": "Kalakand", "ingredients": [ "1 liter milk", "1/2 cup sugar", "1/4 cup khoya (mawa)", "A pinch of cardamom powder", "A few chopped nuts (almonds, pistachios)" ], "recipe": "Kalakand Recipe:\n" "1. Boil the milk in a heavy-bottomed pan and reduce it to half while stirring continuously.\n" "2. Add sugar and continue to cook until it thickens.\n" "3. Add khoya and cardamom powder. Mix well and cook until it thickens further.\n" "4. Transfer the mixture to a greased plate, flatten it, and garnish with chopped nuts.\n" "5. Let it cool and set before cutting into kalakand pieces." }, { "title": "Khaja", "ingredients": [ "2 cups all-purpose flour", "1/2 cup ghee", "1/2 cup water", "For Sugar Syrup:", "1 cup sugar", "1/2 cup water", "A pinch of cardamom powder" ], "recipe": "Khaja Recipe:\n" "1. In a mixing bowl, combine all-purpose flour and ghee to form a crumbly mixture.\n" "2. Gradually add water and knead the mixture into a smooth dough.\n" "3. Roll out the dough into thin sheets and cut them into diamond-shaped pieces.\n" "4. Heat oil in a pan and deep fry the dough pieces until they are golden and crisp.\n" "5. Make sugar syrup by boiling sugar and water until it forms a one-string consistency. Add cardamom powder.\n" "6. Dip the fried khaja in the sugar syrup for a few seconds and let them cool before serving." }, { "title": "Kheer", "ingredients": [ "1/2 cup rice", "4 cups milk", "1/2 cup sugar", "A pinch of cardamom powder", "A few chopped nuts (cashews, almonds, pistachios)", "A few saffron strands" ], "recipe": "Kheer Recipe:\n" "1. Wash and soak rice for about 30 minutes.\n" "2. Cook the rice in milk until it's soft and the mixture thickens.\n" "3. Add sugar and continue to cook until the kheer thickens further.\n" "4. Add cardamom powder, chopped nuts, and saffron strands. Mix well.\n" "5. Serve the creamy and delicious kheer." }, { "title": "Kheer Kadam", "ingredients": [ "1/2 cup chhena (paneer)", "1/2 cup khoya (mawa)", "1/4 cup sugar", "1/4 cup milk", "A pinch of cardamom powder", "A few chopped nuts (cashews, pistachios)" ], "recipe": "Kheer Kadam Recipe:\n" "1. In a mixing bowl, combine chhena and khoya. Knead them together to form a smooth mixture.\n" "2. Roll the mixture into small balls (kadam) and keep aside.\n" "3. In a separate saucepan, heat sugar and milk to make a sugar syrup of one-string consistency.\n" "4. Add cardamom powder to the sugar syrup.\n" "5. Place the khoya-chhena balls (kadam) in the sugar syrup and let them soak for some time.\n" "6. Garnish with chopped nuts and serve the delightful kheer kadam." }, { "title": "Lavang Latika", "ingredients": [ "1 cup all-purpose flour", "2 tbsp ghee", "1/4 cup sugar", "A pinch of cardamom powder", "A few cloves (lavang)" ], "recipe": "Lavang Latika Recipe:\n" "1. In a mixing bowl, combine all-purpose flour and ghee to form a crumbly mixture.\n" "2. Add sugar, cardamom powder, and a little water to make a firm dough.\n" "3. Roll out the dough into small rectangles and wrap a clove (lavang) in each.\n" "4. Deep fry the latikas until they are golden brown.\n" "5. Drain and serve these sweet, clove-studded treats." }, { "title": "Malpua", "ingredients": [ "1 cup all-purpose flour", "1/4 cup semolina (rava)", "1/2 cup milk", "1/4 cup sugar", "A pinch of cardamom powder", "Ghee for frying", "For Sugar Syrup:", "1/2 cup sugar", "1/2 cup water" ], "recipe": "Malpua Recipe:\n" "1. In a mixing bowl, combine all-purpose flour, semolina, milk, sugar, and cardamom powder to make a smooth batter.\n" "2. Heat ghee in a pan and pour a small portion of the batter to make small pancakes (malpua).\n" "3. Fry them until they are golden brown on both sides.\n" "4. Make sugar syrup by boiling sugar and water until it forms a one-string consistency.\n" "5. Dip the malpua in the sugar syrup for a few seconds and serve." }, { "title": "Meethi Seviyan", "ingredients": [ "1 cup vermicelli (seviyan)", "1/4 cup ghee", "1/2 cup sugar", "1 cup milk", "A pinch of cardamom powder", "A few raisins and cashews" ], "recipe": "Meethi Seviyan Recipe:\n" "1. In a pan, roast the vermicelli in ghee until it's golden brown.\n" "2. Add sugar and continue to cook until it melts and caramelizes.\n" "3. Add milk and cook until the seviyan are soft and the mixture thickens.\n" "4. Add cardamom powder and garnish with raisins and cashews.\n" "5. Serve the sweet meethi seviyan." }, { "title": "Modak", "ingredients": [ "1 cup rice flour", "1/2 cup jaggery", "1/2 cup grated coconut", "1/4 tsp cardamom powder", "Ghee for greasing" ], "recipe": "Modak Recipe:\n" "1. Heat jaggery with a little water to make a syrup and strain it.\n" "2. In a pan, combine rice flour and grated coconut. Add the jaggery syrup and cardamom powder.\n" "3. Cook until the mixture leaves the sides of the pan.\n" "4. Cool the mixture a bit, then shape it into modak (dumplings) while it's still warm.\n" "5. Grease the modak molds with ghee and press the mixture into the molds.\n" "6. Remove the modak from the molds when set and serve." }, { "title": "Mysore Pak", "ingredients": [ "1 cup besan (gram flour)", "1 cup sugar", "1/2 cup ghee", "1/4 cup water" ], "recipe": "Mysore Pak Recipe:\n" "1. In a pan, combine sugar and water and make a sugar syrup.\n" "2. Heat ghee in a separate pan and add besan. Roast it until it's aromatic and changes color.\n" "3. Add the sugar syrup to the roasted besan and cook, stirring continuously.\n" "4. The mixture will thicken and start leaving the sides of the pan.\n" "5. Transfer the mixture to a greased plate, let it set, and cut into pieces." }, { "title": "Nankhatai", "ingredients": [ "1 cup all-purpose flour", "1/2 cup besan (gram flour)", "1/2 cup ghee", "1/2 cup powdered sugar", "1/4 tsp cardamom powder" ], "recipe": "Nankhatai Recipe:\n" "1. In a mixing bowl, combine all-purpose flour, besan, ghee, powdered sugar, and cardamom powder.\n" "2. Knead the mixture into a dough.\n" "3. Roll the dough into small round cookies and place them on a baking tray.\n" "4. Bake in a preheated oven at 180°C (350°F) for 15-20 minutes until they are golden brown.\n" "5. Let the nankhatai cool before serving." }, { "title": "Paniyaram", "ingredients": [ "2 cups dosa batter", "1/2 cup finely chopped onions", "2-3 green chilies, finely chopped", "1/4 cup grated coconut", "A few curry leaves", "1 tsp mustard seeds", "1 tsp urad dal", "Oil for frying" ], "recipe": "Paniyaram Recipe:\n" "1. Heat oil in a paniyaram pan and add mustard seeds and urad dal. Let them splutter.\n" "2. Add finely chopped onions, green chilies, and curry leaves. Saute until onions turn translucent.\n" "3. In a bowl, mix the dosa batter and grated coconut. Add the sauteed mixture and mix well.\n" "4. Grease the paniyaram pan with oil, pour the batter into the cavities, and cook until they turn golden and crispy.\n" "5. Serve hot with chutney or sambar." }, { "title": "Papad Roll", "ingredients": [ "Papads (as needed)", "1/2 cup boiled and mashed potatoes", "1/4 cup finely chopped onions", "1/4 cup finely chopped tomatoes", "1/4 cup grated cheese", "1/4 cup chopped bell peppers", "1/4 cup boiled corn", "1/4 tsp chaat masala", "1/4 tsp red chili powder", "Salt to taste" ], "recipe": "Papad Roll Recipe:\n" "1. Roast the papads until crisp and set aside.\n" "2. In a bowl, combine boiled and mashed potatoes, onions, tomatoes, cheese, bell peppers, boiled corn, chaat masala, red chili powder, and salt.\n" "3. Place a portion of this mixture on each roasted papad and roll it up.\n" "4. Secure the rolls with toothpicks and serve as a crispy snack." }, { "title": "Patishapta", "ingredients": [ "1 cup rice flour", "1/2 cup all-purpose flour", "1 cup milk", "1/2 cup jaggery", "1/4 cup grated coconut", "1/4 tsp cardamom powder", "Ghee for frying" ], "recipe": "Patishapta Recipe:\n" "1. In a mixing bowl, combine rice flour, all-purpose flour, milk, and water to make a smooth batter.\n" "2. Heat a non-stick pan and pour a ladleful of batter to make a thin pancake.\n" "3. Cook until it's golden and crispy.\n" "4. In another pan, heat jaggery with a little water to make a syrup.\n" "5. Add grated coconut and cardamom powder to the syrup.\n" "6. Place the coconut-jaggery mixture in the center of the pancake and roll it up.\n" "7. Serve the delicious patishapta." }, { "title": "Peda", "ingredients": [ "1 cup milk powder", "1/2 cup condensed milk", "2 tbsp ghee", "1/4 tsp cardamom powder", "A few chopped pistachios or almonds" ], "recipe": "Peda Recipe:\n" "1. In a non-stick pan, combine milk powder, condensed milk, and ghee.\n" "2. Cook on low heat, stirring continuously, until the mixture thickens.\n" "3. Add cardamom powder and mix well.\n" "4. Allow the mixture to cool slightly.\n" "5. Grease your hands with ghee and shape the mixture into small pedas.\n" "6. Garnish with chopped pistachios or almonds and let them cool completely before serving." }, { "title": "Petha", "ingredients": [ "500g petha (ash gourd)", "1 cup sugar", "1/4 cup water", "A few saffron strands", "1/2 tsp cardamom powder" ], "recipe": "Petha Recipe:\n" "1. Peel and deseed the petha, then cut it into small pieces.\n" "2. In a pan, make sugar syrup by heating sugar and water until it thickens.\n" "3. Add petha pieces to the sugar syrup and cook until they become translucent.\n" "4. Add saffron strands and cardamom powder.\n" "5. Let it cool and serve the sweet petha." }, { "title": "Puran Poli", "ingredients": [ "1 cup chana dal (split chickpeas)", "1 cup jaggery", "1 cup wheat flour", "A pinch of turmeric powder", "A pinch of cardamom powder", "Ghee for frying" ], "recipe": "Puran Poli Recipe:\n" "1. Cook chana dal until soft, then drain and mash it.\n" "2. In a pan, heat jaggery with a little water to make a syrup. Strain it.\n" "3. Add the mashed chana dal to the jaggery syrup, then add cardamom powder and mix well.\n" "4. In a separate bowl, make a dough with wheat flour, turmeric powder, and water.\n" "5. Make small balls of the dough and roll them into small circles.\n" "6. Place a portion of the chana dal-jaggery mixture in the center and seal the edges.\n" "7. Roll it out gently and fry with ghee on a griddle until it's golden brown.\n" "8. Serve the delicious puran poli." }, { "title": "Puri Unde", "ingredients": [ "1 cup powdered jaggery", "2 cups puffed rice", "1/4 cup grated coconut", "A pinch of cardamom powder", "Ghee for greasing palms" ], "recipe": "Puri Unde Recipe:\n" "1. In a mixing bowl, combine powdered jaggery, puffed rice, grated coconut, and cardamom powder.\n" "2. Grease your palms with ghee and shape the mixture into small ladoos (unde).\n" "3. Let them cool and enjoy these quick and easy sweet treats." }, { "title": "Qubani Ka Meetha", "ingredients": [ "1 cup dried apricots (qubani)", "1/2 cup sugar", "1 cup water", "1/4 cup ghee", "2-3 cardamom pods", "A few chopped nuts for garnish" ], "recipe": "Qubani Ka Meetha Recipe:\n" "1. Soak dried apricots in water overnight or until they become soft.\n" "2. Remove the seeds from the apricots and make a smooth paste.\n" "3. In a pan, heat ghee and add the apricot paste. Cook for a few minutes.\n" "4. Add sugar, cardamom pods, and water. Simmer until it thickens and the ghee separates.\n" "5. Garnish with chopped nuts and serve the sweet qubani ka meetha." }, { "title": "Rabri", "ingredients": [ "1 liter full-fat milk", "1/2 cup sugar", "1/4 tsp cardamom powder", "A few saffron strands", "A few chopped nuts for garnish" ], "recipe": "Rabri Recipe:\n" "1. In a heavy-bottomed pan, boil the milk and let it simmer on low heat, stirring occasionally.\n" "2. Add sugar, cardamom powder, and saffron strands. Continue to cook until it thickens.\n" "3. Scrape the cream formed on the sides and add it back to the rabri.\n" "4. Garnish with chopped nuts and serve chilled." }, { "title": "Rajbhog", "ingredients": [ "1 cup paneer (cottage cheese)", "1/4 cup sugar", "A few saffron strands", "A pinch of cardamom powder", "A few chopped nuts for garnish" ], "recipe": "Rajbhog Recipe:\n" "1. In a mixing bowl, crumble the paneer and knead it until smooth.\n" "2. Add sugar, saffron strands, and cardamom powder. Mix well.\n" "3. Shape the mixture into round balls.\n" "4. Garnish with chopped nuts and serve." }, { "title": "Ras Malai", "ingredients": [ "6 rasgullas", "4 cups milk", "1/2 cup sugar", "A pinch of saffron strands", "A pinch of cardamom powder", "A few chopped nuts for garnish" ], "recipe": "Ras Malai Recipe:\n" "1. Squeeze the sugar syrup from rasgullas and flatten them slightly.\n" "2. Boil milk with sugar, saffron strands, and cardamom powder.\n" "3. Add the flattened rasgullas to the milk and simmer until they absorb the flavors.\n" "4. Garnish with chopped nuts and serve chilled." }, { "title": "Rava Kesari", "ingredients": [ "1 cup semolina (rava)", "1/2 cup sugar", "1/4 cup ghee", "1/4 tsp cardamom powder", "A few saffron strands", "A few chopped nuts for garnish" ], "recipe": "Rava Kesari Recipe:\n" "1. In a pan, heat ghee and roast semolina until it turns golden and aromatic.\n" "2. In a separate pan, make sugar syrup with sugar, saffron strands, and cardamom powder.\n" "3. Add the roasted semolina to the sugar syrup and mix well until it thickens.\n" "4. Garnish with chopped nuts and serve the sweet rava kesari." }, { "title": "Sandesh", "ingredients": [ "1 cup paneer (cottage cheese)", "1/4 cup sugar", "1/4 tsp cardamom powder", "A few saffron strands", "A few chopped nuts for garnish" ], "recipe": "Sandesh Recipe:\n" "1. Crumble paneer in a mixing bowl.\n" "2. Add sugar, cardamom powder, and saffron strands. Mix well.\n" "3. Shape the mixture into small sandesh and garnish with chopped nuts." }, { "title": "Sannas", "ingredients": [ "1 cup rice", "1/4 cup grated coconut", "1/4 cup sugar", "1/4 tsp salt", "1/2 tsp yeast", "1/4 cup water" ], "recipe": "Sannas Recipe:\n" "1. Soak rice in water for about 4 hours or overnight.\n" "2. Grind the soaked rice, grated coconut, sugar, and salt to a smooth batter.\n" "3. Dissolve yeast in warm water and add it to the batter. Mix well.\n" "4. Ferment the batter for a few hours until it doubles in volume.\n" "5. Steam the sannas in idli molds for about 15-20 minutes.\n" "6. Serve the fluffy and slightly sweet sannas." }, { "title": "Shahi Tukda", "ingredients": [ "4 slices of bread", "2 cups milk", "1/2 cup sugar", "1/4 tsp cardamom powder", "A few saffron strands", "Ghee for frying", "A few chopped nuts for garnish" ], "recipe": "Shahi Tukda Recipe:\n" "1. Trim the edges of bread slices and cut them into triangles.\n" "2. Heat ghee in a pan and fry the bread triangles until golden brown.\n" "3. Boil milk with sugar, cardamom powder, and saffron strands until it thickens.\n" "4. Arrange the fried bread triangles in a serving dish and pour the thickened milk over them.\n" "5. Garnish with chopped nuts and serve the royal shahi tukda." }, { "title": "Shakarpara", "ingredients": [ "2 cups all-purpose flour", "1/2 cup semolina (sooji)", "1/2 cup sugar", "1/4 cup ghee", "1/4 tsp cardamom powder", "A pinch of baking soda", "Oil for deep frying" ], "recipe": "Shakarpara Recipe:\n" "1. In a mixing bowl, combine all-purpose flour, semolina, sugar, ghee, cardamom powder, and baking soda.\n" "2. Knead the mixture into a stiff dough using water.\n" "3. Roll out the dough into a thin sheet and cut it into diamond or square shapes.\n" "4. Heat oil in a pan and deep fry the shakarpara until they are golden and crisp.\n" "5. Drain and cool before serving." }, { "title": "Shrikhand", "ingredients": [ "2 cups hung curd (strained yogurt)", "1/2 cup sugar", "1/4 tsp cardamom powder", "A few saffron strands", "A few chopped nuts for garnish" ], "recipe": "Shrikhand Recipe:\n" "1. In a mixing bowl, combine hung curd, sugar, and cardamom powder.\n" "2. Mix well until you get a smooth and creamy consistency.\n" "3. Add saffron strands and mix.\n" "4. Garnish with chopped nuts and chill before serving." }, { "title": "Shufta", "ingredients": [ "1 cup mixed nuts (almonds, cashews, walnuts)", "1/2 cup sugar", "1/4 cup ghee", "1/4 tsp cardamom powder", "A pinch of saffron strands", "1/4 cup desiccated coconut" ], "recipe": "Shufta Recipe:\n" "1. Heat ghee in a pan and roast mixed nuts until they turn golden.\n" "2. Add sugar and cook until it caramelizes.\n" "3. Add cardamom powder, saffron strands, and desiccated coconut. Mix well.\n" "4. Cool and break into pieces before serving." }, { "title": "Singuare Atte Ki Barfi", "ingredients": [ "1 cup water chestnut flour (singhare atta)", "1/2 cup sugar", "1/4 cup ghee", "A pinch of cardamom powder", "A few chopped nuts for garnish" ], "recipe": "Singhare Atte Ki Barfi Recipe:\n" "1. In a pan, heat ghee and roast water chestnut flour until it turns aromatic.\n" "2. Add sugar and cardamom powder. Mix well and cook until it thickens.\n" "3. Transfer to a greased plate, garnish with chopped nuts, and let it cool before cutting into barfi." }, { "title": "Sohan Papdi", "ingredients": [ "1 cup besan (gram flour)", "1 cup sugar", "1/2 cup ghee", "A pinch of cardamom powder", "A few chopped nuts for garnish" ], "recipe": "Sohan Papdi Recipe:\n" "1. Heat ghee in a pan and add besan. Roast until it turns golden and aromatic.\n" "2. Add sugar and cardamom powder. Mix well and quickly transfer to a greased plate.\n" "3. Flatten it, garnish with chopped nuts, and let it cool before breaking into pieces." }, { "title": "Sutarfeni", "ingredients": [ "1 cup fine vermicelli", "1/2 cup ghee", "1/2 cup sugar", "A pinch of cardamom powder", "A few saffron strands", "A few chopped nuts for garnish" ], "recipe": "Sutarfeni Recipe:\n" "1. Heat ghee in a pan and roast fine vermicelli until it turns golden.\n" "2. In a separate pan, make sugar syrup with sugar, cardamom powder, and saffron strands.\n" "3. Add the roasted vermicelli to the sugar syrup and mix well.\n" "4. Garnish with chopped nuts and serve the delicate sutarfeni." } ] col1, col2 = st.columns(2) my_upload = st.sidebar.file_uploader("Upload an image", type=["png", "jpg", "jpeg","webp"]) st.write() st.markdown("""---""") st.write() if my_upload is not None: st.image(my_upload, caption="Uploaded Image", use_column_width=True) if st.sidebar.button("Classify"): st.sidebar.text("Classifying...") image = Image.open(my_upload) try: classification_result = image_classifier(image) top_prediction = classification_result[0] label = top_prediction['label'] #score = top_prediction['score'] st.sidebar.text("Top Prediction:") # st.sidebar.text(f"Label: {label}, Score: {score:.3f}") st.sidebar.text(f"Label: {label}") except Exception as e: st.error(f"Error during classification: {str(e)}") if my_upload.size > MAX_FILE_SIZE: st.error("The uploaded file is too large. Please upload an image smaller than 5MB.") else: fix_image(upload=my_upload) else: fix_image("jalebi.jpg") # Recipe generation based on selected item st.write("## Recipe Generation") selected_item = st.selectbox("Select a food item", [entry["title"] for entry in dataset]) if st.button("Generate Recipe"): matching_entries = [entry for entry in dataset if entry["title"] == selected_item] if matching_entries: selected_entry = random.choice(matching_entries) title = selected_entry["title"] # Replace spaces with plus (+) for a valid YouTube search query youtube_query = '+'.join(title.split()) youtube_link = f"https://www.youtube.com/results?search_query={youtube_query}+recipe" ingredients = selected_entry["ingredients"] recipe = selected_entry["recipe"] else: title = "Default Recipe Title" ingredients = [] recipe = "No recipe found for this item." youtube_link = "" st.write(f"Generated Recipe for {title}:\n") st.write(f"Ingredients: {', '.join(ingredients)}") st.write(f"Instructions: {recipe}") # Display YouTube link st.write(f"YouTube Recipe Link: [{title} Recipe]({youtube_link})") # Add some descriptions and instructions st.sidebar.markdown("### Instructions") st.sidebar.markdown("1. Upload an image.") st.sidebar.markdown("2. Click the 'Classify' button to get the classification results.") st.sidebar.markdown("3. Select a food item to generate a recipe.") st.sidebar.markdown("4. Click the 'Generate Recipe' button to get the recipe.") # Display a placeholder for the main content st.write("Please upload an image and use the sidebar to classify it and generate a recipe.")