Prompt: Food photography, powerful explosion of yellow dust of a shrimp taco, studio light, black plain background, studio lighting
炸虾卷的黄色粉尘(肉松)爆炸了
Flames and Sparks(跳动的火焰)
Prompt: Food photography, grilled chicken stew on the bbq rack, with flames and sparks
用火焰和火花炖烤鸡
Water Splashing(果汁四溅)
Prompt: Commercial photography, a watermelon dropping, water splashing around, tropical background, low angle
西瓜掉落,水花飞溅
Hitting on the table(与桌面的碰撞)
Prompt: Food Photography, a pile of nachos hitting on the table, with cheese, tomato, onion and lime, front shot
玉米片沙拉砸在桌子上
Dripping(垂涎欲滴)
Prompt: Food phototgraphy, chocolate sauce dripping, onto a pile of pancake, with whipped cream and strawberry, front shot
正在滴落的巧克力酱
..技巧一:微距拍摄
使用“微距镜头”捕捉食物的复杂细节、纹理或运动,以唤起感官体验。
滴蜜-复杂的质地
Prompt: Food photography, macro shot, honey dripping, color hierachy, light and shade contrast, dof
蜂蜜在滴落
奶酪拉丝-令人垂涎的动作
Prompt: Food Photography, peperroni cheese pizza, macro shot, cheese pull of a slice, focus on the cheese and vibrant toppings
意大利辣香肠芝士披萨加芝士拉丝
水滴-强调新鲜
Prompt: Food photography, a peach, macroshot of water droplets, front light
水蜜桃的微距镜头
2. Angle(角度)
借助拍摄角度,摄影师可以强调场景中的某些元素,并在图像中传达某种情绪或情感。
Back Angle——背面
Front View——正面视角
High Angle——高角度
Low Angle——低角度
Profile Angle ——产品的侧面
High Angle(高角度)
Prompt: Food Photography, a creamy tomato soup with a swirl of fresh cream, topped with crispy croutons and a sprinkle of basil, high angle
奶油番茄汤,高角度
Low Angle(低角度)
Prompt: Commerical photography, a glass of lemonade, surrounded by lemon and mint, low angle, blue sky background, water droplets and splashing, sunlight
一杯柠檬汁
Front View(正面视角)
Prompt: Commerical photography, a glass of green tea, sitting on a wood, a branch lying around, front view, soft lighting, clean light leige background, minimal and zen
2. Composition(视觉构成)
注意食物在框架内的排列和放置。使用三分法、对称和负空间来创造视觉上吸引人的构图。
Asymmetrical Composition——不对称构图
Diagonal Composition——对角构图
Geometric composition——几何构图
Knolling——Knolling拍法(全家福拍法)
Symmetrical Composition——对称构图
Rule of Thirds——三分法
Knolling拍摄法
Prompt: Knolling of [ country ] cuisine, professional food photography, on a long table, realistic, depth of field — ar 3:1
泰国菜全家福拍摄
日料全家福
对称构图
Prompt: Commerical photography, Japanese pastries, sakura pastry shape, sakura decoration, symmetrical compostion, high end silk red table cloth with pattern, studio light
日式糕点,对称构图
..技巧二:配菜
考虑一些色彩鲜艳的装饰,比如新鲜的食材,以增强视觉吸引力。以吸引人的方式安排食物和伴随的道具。
食用花卉和水果
Prompt: Commercial photograph, a tropical fruit sorbet, center composition, surrouded by edible flowers and tropical fruits, beautiful sunlight
热带水果冰沙
多彩的果蔬
Prompt: Commercial Photography, sizzling steak, with grill marks, adorned with fresh herbs and colorful vegetables
牛排周边的多种颜色果蔬
4. 灯光
适当的照明对于突出食物的纹理、颜色和细节至关重要。
Advanced Lighting——高级照明
Beautiful Sunlight——魅力阳光
Morning Light——晨光
Natural Light——自然光
Soft Shadow Light——柔和阴影光线
Studio Lighting——工作室照明
Sunlighting——阳光
Volumetric Lighting——体积光
自然光
Prompt: Commercial Photography, a refreshing summer cocktail, with sparkling ice cubes, slices of citrus fruits, and sprigs of fragrant herbs, natural lighting on a hot day.
工作室(影棚)灯光
Prompt: Extreme close-up shot of a chocolate cake, oozing with molten ganache and adorned with luscious berries, depth of field, studio lighting
5. 添加一些设置
在prompt中包含设置可以为您的受众提供更具体的上下文。根据不同的设置,样式可以有很大的不同。
Classic——经典
Elegant——优雅
Luxurious——奢华
Minimal——极简
Romantic——浪漫
Serene——清澈宁静
Tropical——热带
Luxurious & High End(奢华高端)
Prompt: Commerical photography, a bottle of red wine, luxurious and high end, flowers, red wall, beautiful lighting and shadow from the window
Serene & Calm(安详与宁静)
Prompt: A croissant and a cup of coffee, warm enviornment, in a minimalist style living room, beige and white, serene and calm, monochrome scheme, light-filled landscape
极多主义Coffee Shop
Prompt: Commerical photography, a cup of latte, in a maximalist style coffee shop, dusk blue and terracotta and cantaloupe color
在极多主义风格的咖啡店里喝一杯拿铁
..技巧三:添加材料
为了增强食物摄影的真实感和专业性,可以考虑整合石头或木材等元素。
将它们用作台面或背景,以提高美学吸引力和真实性。
法国浪漫与大理石石桌
Prompt: Food photography, high angle, a glass of peach soda, on a marble stone table, with peaches and flowers beside, beautiful sunlight and shadow, French romance
大理石石头上的一杯桃子苏打水
木质斑纹
Prompt: Commercial photography, a glass of whisky, high angle shot, wooden mottled grain background, warm tones, light contrast
Prompt: Food photography, creative halloween dessert, with style of spider, skull, ontrasting colors, textures, and symmetry to create a visually striking composition
创意万圣节甜点——鬼点心
微型摄影
微型摄影可以创造性地展示您的产品或您的菜肴中使用的新鲜成分,提供引人入胜的视觉呈现。
Prompt: Miniature Scenery of a miniature figurines playing in a small slice of watermelon, light background, intricate details, soft color blending
Prompt: Interior design of a luxury bathroom, designed by Kelly Wearstler, natural color scheme— ar 16:9
20. Karim Rashid(卡里姆·拉希德)
卡里姆被誉为全美洲最著名的工业设计师和“塑料王子”。
Prompt: Interior design of a cafe, designed by Karim Rashid, concrete and glass facade, outdoor forest, natural light with warm tones, breathtaking — ar 16:9
21. Vincent Van Duysen(文森特·范·杜伊森)
文森特以高端住宅和永恒的设计风格而闻名,擅长使用灌注的混凝土设计各种室内装饰,如桌子、台灯等
Prompt: Interior view of a bold rammed earth and oak mid century modern house, designed by Vincent Van Duysen, sitting on a desert land facing the mountains, moroccan warm light fixtures — ar 16:9
22. India Mahdavi(印度马达维)
印度被称为“色彩大师”和“完美音高的拥有者”的建筑师和设计师
Prompt: The most Instagrammed bar in the world, designed by India Mahdavi, vivid ceramics — ar 16:9
23. UI设计师Leo Natsume
Leo Natsume风格以其独特,生动的插图而脱颖而出,这些插图是喜剧和怪诞的结合。
Prompt: Interior design of a studio, trending color palette, by Leo Natsume, 3D illustration, pop up color, vibrant — ar 16:9
24. Yayoi Kusama(草间弥生)
最著名的现代日本艺术家之一,以她在作品中独特的波尔卡圆点而闻名。
Prompt: Interior design of a bedroom, by Yayoi Kusama — ar 16:9
25. Tim Burton(蒂姆伯顿)
美国导演和动画师,以其黑暗奇幻和恐怖电影而闻名
Prompt: Interior design of a living room, by Tim burton — ar 16:9
我们来看看电影的风格
26. Harry Potter(哈利波特)
Prompt: Interior design of livin room, harry potter theme — ar 16:9
27. Alice in Wonderland(爱丽丝梦游仙境)
Prompt: Interior design of a bathroom, in the style of alice in wonderland, dreamy, breathtaking, beautiful sunlight — ar 16:9
28. Disney & Cartoon(迪士尼动漫)
迪士尼和卡通风格是为你的小公主和王子创造梦想房间的完美选择。
Prompt: Interior design of a room for a baby boy, pastel color, blue and white, Disney, diorama, cartoon, — ar 16:9
也可以用最新的niji5效果,可以让上面的设计发生很有趣的变化.
Prompt: Interior design of a room for a baby boy, pastel color, blue and white, Disney, diorama, cartoon, — ar 16:9 — niji v 5 — style scenic
29. 未来主义2080
让我们游历未来的室内空间设计
Prompt: Interior design of a bedroom, futuristic, in 2080, sci-fi, C4D rendering, smooth lighting, clean, neon light, advanced technology, intelligent housing appliances — ar 16:9
30. Cyberpunk(赛博朋克)
Prompt: Interior design of a music studio room, cyberpunk — ar 16:9
31. Ice Cave(冰洞)
Prompt: Interior design of an ice cave hotel , glowing, translucent, natural lighting, blue and white, hyper detailed, 8k — ar 16:9
32. Intertwining Materials(交织设计)
Prompt: An interior inside of a tree, in the style of realistic yet ethereal, monumental architecture, organic forms, muted tones, 32k uhd, intertwining materials, intricate ceiling designs— ar 16:9
LlamaIndex(也称为GPT Index)是一个用户友好的界面,它将您的外部数据连接到大型语言模型(Large Language Models, llm)。它提供了一系列工具来简化流程,包括可以与各种现有数据源和格式(如api、pdf、文档和SQL)集成的数据连接器。此外,LlamaIndex为结构化和非结构化数据提供索引,可以毫不费力地与大语言模型一起使用。
from llama_index import GPTKeywordTableIndex, SimpleDirectoryReader from IPython.display import Markdown, display from langchain.chat_models import ChatOpenAI
## by default, LlamaIndex uses text-davinci-003 to synthesise response # and text-davinci-002 for embedding, we can change to # gpt-3.5-turbo for Chat model index = GPTListIndex.from_documents(documents)
query_engine = index.as_query_engine() response = query_engine.query("What is net operating income?") display(Markdown(f"<b>{response}</b>"))
## Check the logs to see the different between th ## if you wish to not build the index during the index construction # then need to add retriever_mode=embedding to query engine # query with embed_model specified query_engine = new_index.as_query_engine( retriever_mode="embedding", verbose=True ) response = query_engine.query("What is net operating income?") display(Markdown(f"<b>{response}</b>"))
index = GPTVectorStoreIndex.from_documents(documents) query_engine = index.as_query_engine() response = query_engine.query("What did the author do growing up?") response
new_index = GPTTreeIndex.from_documents(documents) response = query_engine.query("What is net operating income?") display(Markdown(f"<b>{response}</b>"))
## if you want to have more content from the answer, # you can add the parameters child_branch_factor # let's try using branching factor 2 query_engine = new_index.as_query_engine( child_branch_factor=2 ) response = query_engine.query("What is net operating income?") display(Markdown(f"<b>{response}</b>"))
from llama_index import GPTKeywordTableIndex index = GPTKeywordTableIndex.from_documents(documents) query_engine = index.as_query_engine() response = query_engine.query("What is net operating income?")
for year in years: year_docs = loader.load_data(f'../notebooks/documents/Apple-Financial-Report-{year}.pdf', split_documents=False) for d in year_docs: d.extra_info = {"quarter": year.split("-")[0], "year": year.split("-")[1], "q":year.split("-")[0]} doc_set[year] = year_docs all_docs.extend(year_docs)
为每个季度创建矢量指数。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
## setting up vector indicies for each year #--- # initialize simple vector indices + global vector index # this will use OpenAI embedding as default with text-davinci-002 service_context = ServiceContext.from_defaults(chunk_size_limit=512) index_set = {} for year in years: storage_context = StorageContext.from_defaults() cur_index = GPTVectorStoreIndex.from_documents( documents=doc_set[year], service_context=service_context, storage_context=storage_context ) index_set[year] = cur_index # store index in the local env, so you don't need to do it over again storage_context.persist(f'./storage_index/apple-10k/{year}')
从树索引生成摘要。如前所述,Tree Index对于总结文档集合很有用。
1 2
# describe summary for each index to help traversal of composed graph index_summary = [index_set[year].as_query_engine().query("Summary this document in 100 words").response for year in years]
### Composing a Graph to Synthesize Answers from llama_index.indices.composability import ComposableGraph
from langchain.chat_models import ChatOpenAI from llama_index import LLMPredictor
# define an LLMPredictor set number of output tokens llm_predictor = LLMPredictor(llm=ChatOpenAI(temperature=0, max_tokens=512, model_name='gpt-3.5-turbo')) service_context = ServiceContext.from_defaults(llm_predictor=llm_predictor) storage_context = StorageContext.from_defaults()\
## define a list index over the vector indicies ## allow us to synthesize information across each index graph = ComposableGraph.from_indices( GPTListIndex, [index_set[y] for y in years], index_summaries=index_summary, service_context=service_context, storage_context=storage_context )
root_id = graph.root_id
#save to disk storage_context.persist(f'./storage_index/apple-10k/root')
## querying graph custom_query_engines = { index_set[year].index_id: index_set[year].as_query_engine() for year in years }
# NOTE: the table_name specified here is the table that you # want to extract into from unstructured documents. index = GPTSQLStructStoreIndex.from_documents( wiki_docs, sql_database=sql_database, table_name="city_stats", service_context=service_context )
# view current table to verify the answer later stmt = select( city_stats_table.c["city_name", "population", "country"] ).select_from(city_stats_table)
with engine.connect() as connection: results = connection.execute(stmt).fetchall() print(results)
query_engine = index.as_query_engine( query_mode="nl" ) response = query_engine.query("Which city has the highest population?")
withopen(data_path / f"{title}.txt", 'w') as fp: fp.write(wiki_text)
# Load all wiki documents city_docs = [] for wiki_title in wiki_titles: docs = SimpleDirectoryReader(input_files=[f"data/{wiki_title}.txt"]).load_data() docs[0].doc_id = wiki_title city_docs.extend(docs)
# default mode of building the index response_synthesizer = ResponseSynthesizer.from_args(response_mode="tree_summarize", use_async=True) doc_summary_index = GPTDocumentSummaryIndex.from_documents( city_docs, service_context=service_context, response_synthesizer=response_synthesizer )
import logging import sys import os os.environ["OPENAI_API_KEY"] = "<your_openai_api_key>"
from llama_index import SimpleDirectoryReader, LLMPredictor, ServiceContext, StorageContext, LangchainEmbedding from llama_index import GPTVectorStoreIndex from langchain.chat_models import ChatOpenAI from langchain.embeddings import HuggingFaceEmbeddings from langchain.embeddings.openai import OpenAIEmbeddings from llama_index import ResponseSynthesizer
withopen(data_path / f"{title}.txt", 'w', encoding="utf-8") as fp: fp.write(wiki_text)
阅读所有的文件。我只拿纽约和休斯顿做比较。
1 2 3 4 5 6 7 8 9 10 11
docs= ['New York City','Houston.txt'] all_docs = {} for d in docs: doc = SimpleDirectoryReader(input_files=[f"./data/{d}"]).load_data() nodes = parser.get_nodes_from_documents(doc) doc_id = d.replace(" ","_") doc[0].doc_id = d ## this can be used for metadata filtering if need extra_info = {"id":d} doc[0].extra_info = extra_info all_docs[d] = doc
index_existed = False for d in all_docs.keys(): print(f"Creating/Updating index {d}") if index_existed: ## update index print(f"Updating index: {d}") # index_node.insert_nodes(all_nodes[d]) index.insert(all_docs[d][0]) else: print(f"Creating new index: {d}") index = GPTVectorStoreIndex.from_documents( all_docs[d], service_context=service_context, storage_context=storage_context ) index_existed = True
现在,让我们用几个查询进行实验
1
index.as_query_engine().query("What is population of New York?")
没错,这个查询只是简单地从文档中查找纽约市的人口。我们将与休斯顿市再次合作
1
index.as_query_engine().query("What is population of Houston?")
# configure retriever from llama_index.retrievers import VectorIndexRetriever from llama_index.query_engine import RetrieverQueryEngine
# this will simple do the vector search and return the top 2 similarity # with the question being asked. retriever = VectorIndexRetriever( index=index, similarity_top_k=2, )
# configure response synthesizer response_synthesizer = ResponseSynthesizer.from_args(verbose=True) ## if you nee to pass response mode # response_synthesizer = ResponseSynthesizer.from_args( # response_mode='tree_summarize', # verbose=True)
# query response = query_engine.query(""" Compare the population of New York and Houston. What is the percentage difference between two populations? """)
Here, I asked a similar question but also ask the LLM model to spit the percentage difference between the two populations. And here is the result
*The population of New York City in 2020 was 8,804,190, while the population of Houston in 2020 was 2,320,268. This means that the population of New York City is approximately 278% larger than the population of Houston.*
It’s quite amusing to witness how LLM excels at retrieving information but falls short in accurately calculating numbers. For instance, the state “***New York City is approximately 278% larger than the population of Houston.” ***is correct but we are not asking how the bigger population of New York compare to Houston. We are asking about the “percentage difference” between the two populations.
So, how do we find the percentage difference (% difference calculator) between two positive numbers greater than 0 anyway?
Here is the correct formula for V1 and V2, assuming V1 is bigger than V2
import logging import sys import os os.environ["OPENAI_API_KEY"] = “<your openai api key>" ## load all the necessary components from langchain.embeddings.openai import OpenAIEmbeddings from langchain.vectorstores import Chroma from langchain.text_splitter import CharacterTextSplitter from langchain.llms import OpenAI from langchain.chat_models import ChatOpenAI from langchain.chains import RetrievalQA from langchain.document_loaders import PyPDFLoader, TextLoader from langchain.document_loaders import UnstructuredFileLoader
使用自定义的embedding
1 2 3 4 5 6 7
from langchain.chat_models import ChatOpenAI from langchain.embeddings import HuggingFaceEmbeddings from langchain.embeddings.openai import OpenAIEmbeddings
docs= ['New York City','Houston.txt'] all_docs = [] for d in docs: print(f"#### Loading data: {d}") doc = UnstructuredFileLoader(f"./data/{d}", strategy="hi_res").load() doc = text_splitter.split_documents(doc) all_docs.extend(doc)
## add to vector store vectorstore.add_documents(all_docs)
创建问答链
1 2 3 4 5
qa = RetrievalQA.from_chain_type(llm=ChatOpenAI(temperature=0.2,model_name='gpt-3.5-turbo'), chain_type="stuff", retriever=vectorstore.as_retriever()) result = qa({"query": "Compare the population of New York and Houston. What is the percentage difference between two populations?"}) result
from langchain.agents import initialize_agent, Tool from langchain.agents import AgentType from langchain.tools import BaseTool
tools = [ Tool( name="general knowledge", func=qa.run, description="useful for when you need to answer questions about the documents in the database" ), Tool( name="llm-math", func=llm_math.run, description="Useful for when you need to answer questions about math." ) ]
# Accessing the OPENAI KEY import environ env = environ.Env() environ.Env.read_env() API_KEY = env('OPENAI_API_KEY')
# Simple LLM call Using LangChain llm = OpenAI(model_name="text-davinci-003", openai_api_key=API_KEY) question = "Which language is used to create chatgpt ?" print(question, llm(question))
# Accessing the OPENAI KEY import environ env = environ.Env() environ.Env.read_env() API_KEY = env('OPENAI_API_KEY')
# Creating a prompt template and running the LLM chain from langchain import PromptTemplate, LLMChain template = "What are the top {n} resources to learn {language} programming?" prompt = PromptTemplate(template=template,input_variables=['n','language']) chain = LLMChain(llm=llm,prompt=prompt) input = {'n':3,'language':'Python'} print(chain.run(input))
import environ env = environ.Env() environ.Env.read_env()
# Establish a connection to the PostgreSQL database conn = psycopg2.connect( host='localhost', port=5432, user='postgres', password=env('DBPASS'), database=env('DATABASE') )
# Create a cursor object to execute SQL commands cursor = conn.cursor()
# Create the tasks table if it doesn't exist cursor.execute('''CREATE TABLE IF NOT EXISTS tasks (id SERIAL PRIMARY KEY, task TEXT NOT NULL, completed BOOLEAN, due_date DATE, completion_date DATE, priority INTEGER)''')
# Create db chain QUERY = """ Given an input question, first create a syntactically correct postgresql query to run, then look at the results of the query and return the answer. Use the following format: Question: Question here SQLQuery: SQL Query to run SQLResult: Result of the SQLQuery Answer: Final answer here {question} """
# Setup the database chain db_chain = SQLDatabaseChain(llm=llm, database=db, verbose=True)
defget_prompt(): print("Type 'exit' to quit")
whileTrue: prompt = input("Enter a prompt: ")
if prompt.lower() == 'exit': print('Exiting...') break else: try: question = QUERY.format(question=prompt) print(db_chain.run(question)) except Exception as e: print(e)